n8n 自动多语言 Gmail 草稿回复(GPT-4o)
Gmail 标签触发 → GPT-4o 评估与语言检测 → 分支生成日/英草稿 → 保存为 Gmail 回复草稿
- 给谁
- 需要处理大量多语言 Gmail 咨询、希望减少手动拟稿的客户支持或业务人员
- 你会得到
- 收到带指定标签的新邮件后,自动判断是否需要回复、识别语言,并生成对应语种的草稿回复存入原会话
硬约束
前置条件:可访问的 n8n 实例;Gmail OAuth2 凭证;OpenAI API 凭证。在 Gmail 中预先创建标签(如 Inquiry)并应用于目标邮件。工作流以轮询方式监听该标签的新邮件,默认每分钟一次。当前模板内置日语与英语两条分支,扩展其他语言需在 Switch 节点新增规则并配置对应生成节点的 system 提示词。
他们做了什么
作者 henry 在 n8n 官方模板库发布了该工作流模板。模板展示了一个端到端流程:通过 Gmail Trigger 轮询带特定标签的新邮件,使用 GPT-4o 判断邮件是否需要回复并识别语言,经 Switch 节点按日语/英语分流后,由两个独立的 LLM Chain 节点分别生成符合对应文化习惯的草稿回复,最终通过 Gmail 节点将文本转为 HTML 并保存为原会话的回复草稿。
效果如何
模板在 n8n 平台显示为已发布状态(status: published),截至采集时累计浏览量 2523 次(author_report)。来源未提供具体的回复准确率、用户满意度或 ROI 数据。
值得知道
本站未实测该工作流(reproduction=not_tested)。实际部署需要有效的 Gmail OAuth2 与 OpenAI API 凭证;GPT-4o 调用会产生费用。当前模板仅内置日语与英语分支,其他语言需自行扩展 Switch 规则并撰写对应 system 提示词。提示词中包含硬编码的称呼占位符,需根据实际业务替换。营销邮件被显式排除在自动回复之外(needsReply=false)。轮询频率影响响应及时性与 API 调用成本,需按业务量调整。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- Gmail trigger 与 Gmail - Create Draft 绑定同一测试 Gmail 账号的 OAuth2 凭证。
- 三个 OpenAI GPT-4o 模型节点绑定自己的 OpenAI API 凭证。邮件正文会提交给该服务处理。
需要替换的配置
- 源模板 Gmail trigger 的 filters.q 为空,会造成范围过宽。首次测试前,先在测试邮箱建立专用标签,再在触发器 Search 查询填写对应 label:标签名,切勿直接启用。
- 轮询默认每分钟一次;根据使用量调整。原模板只定义日语和英语分支,其他语言走英文分支,扩展语言须补充路由与提示词。
- 日语提示词包含公司、姓名和客户名占位符,需自行填写。Parser Result 的 schema 是数组,而后续表达式读取顶层 needsReply/message_language;逐段测试时核对输出形状,失败先修正自己的副本。
测试输入与预期结果
- 在测试邮箱发送一封带专用标签的英文或日文咨询,抓取一条测试邮件;检查 needsReply、message_language、语言分支和生成草稿。
- 确认草稿在原 threadId 会话中、收件人和主题正确;该模板创建 draft,没有自动发送节点。审核内容后再由人发送。
- 再用一封无需回复的营销测试邮件检查 false 分支;不要用真实客户邮件批量试跑。
模板处理说明
- 已移除原作者凭证绑定、实例标识和执行测试数据,设为未启用;节点、连线和原文提示词保持原样。未在 n8n 中实际运行。
- 没有自动添加标签或改变语言分支、解析器及提示词;上述源模板配置差异需在运行前核对。
模板获取日期: 2026-10-24
步骤
配置 Gmail 触发器
在 n8n 中添加 Gmail Trigger 节点,连接 Gmail OAuth2 凭证。在 Gmail 中为目标邮件添加标签(如 Inquiry),并在节点中配置对应标签过滤。注意:源模板触发器的 Search 查询(filters.q)为空,不按标签过滤,范围过宽;首次测试前,务必先在测试邮箱建立专用测试标签,并在 filters.q 填写 label:测试标签名,再运行测试。根据业务需要调整轮询间隔(pollTimes)。触发后节点会输出邮件的 subject、textAsHtml、headers.from、threadId 等字段,供后续节点引用。
评估邮件并识别语言
添加 Basic LLM Chain 节点( Assess if a message needs a reply and identify the language ),连接 OpenAI GPT-4o 模型节点(model=gpt-4o,temperature=0,responseFormat=json_object)与 Structured Output Parser 节点。在 LLM Chain 的 prompt 字段中输入邮件主题与正文;在 messages 中放入 system 提示词,要求模型判断 needsReply(boolean)与 message_language(English / Japanese / Other)并返回 JSON。Parser 的 JSON Schema 需包含 needsReply 与 message_language 两个必填字段。
运行提示词 · 来源原文。Basic LLM Chain 节点的 prompt 字段(邮件内容输入)
=Subject: {{ $json.subject }} Message: {{ $json.textAsHtml }}运行提示词 · 来源原文。Basic LLM Chain 节点的 messages.messageValues[0].message(system 提示词)
Your task is to : - identify the language of the message and set the value to field "message_language" : "English", "Japanese" or "Other" - assess if the message requires a response and set the value to field "needsReply" : true if it does, false otherwise. Return in JSON format. Marketing emails don't require a response.
运行提示词 · 来源原文。Structured Output Parser 节点的 jsonSchema 字段
={ "type": "array", "items": { "type": "object", "properties": { "needsReply": { "type": "boolean" }, "message_language": { "type": "string" } }, "required": ["needsReply", "message_language"] } }按语言分流
添加 If 节点判断 needsReply 是否为 true;为 true 时进入 Switch 节点。Switch 根据 message_language 字段值路由:等于 Japanese 走「日语版」分支,等于 English 走「英语版」分支。fallbackOutput 设为 1(English)。若需扩展其他语言,在 Switch 中新增规则并连接对应的生成节点。
生成对应语言的草稿回复
在日语分支放置 Basic LLM Chain 节点(Generate email for a Japanese client),在英语分支放置另一 Basic LLM Chain 节点(Generate email reply for an English client)。两节点均连接各自的 OpenAI GPT-4o 模型子节点。节点的 text 字段引用 Gmail trigger 的 subject 与 textAsHtml;messages 中分别放入日语/英语 system 提示词,定义语气、称呼、结尾、占位符规则及 yes-no 双版本输出格式。
运行提示词 · 来源原文。Generate email for a Japanese client 与 Generate email reply for an English client 节点的 text 字段(邮件内容输入)
=Subject: {{ $('Gmail trigger').item.json.subject }} Message: {{ $('Gmail trigger').item.json.textAsHtml }}运行提示词 · 来源原文。Generate email for a Japanese client 节点的 messages.messageValues[0].message(日语生成 system 提示词)
You're a helpful personal assistant and your task is to draft replies on my behalf to my incoming emails. Whenever I provide some text from an email, return an appropriate draft reply for it and nothing else. Ensure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner. Do not make things up. Detailed instructions: - Be concise and maintain a business tone (desu-masu). - Follow the following content [INSERT CLIENT NAME] 様 お世話になっております。 株式会社 [INSERT YOUR COMPANY NAME] の[INSERT YOUR NAME]です。 BODY (main content) 引き続き、何卒どうぞ宜しくお願いいたします。 - When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by " - - - - - - - OR - - - - - - - " - If you don't know an answer, you can leave placeholders like "[YOUR_ANSWER_HERE]". - Don't use any special formatting, only plain text. - Make sure each request is separated with a new line break - Reply in the same language as the inbound email.
运行提示词 · 来源原文。Generate email reply for an English client 节点的 messages.messageValues[0].message(英语生成 system 提示词)
You're a helpful personal assistant and your task is to draft replies on my behalf to my incoming emails. Whenever I provide some text from an email, return an appropriate draft reply for it and nothing else. Ensure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner. Do not make things up. Detailed instructions: - Be concise and maintain a business casual tone. - Start with "Dear,", and end with "Best regards," - When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by " - - - - - - - OR - - - - - - - " - If you don't know an answer, you can leave placeholders like "[YOUR_ANSWER_HERE]". - Don't use any special formatting, only plain text. - Reply in the same language as the inbound email.
保存为 Gmail 回复草稿
添加 Gmail 节点(Gmail - Create Draft),resource 设为 draft,emailType 设为 html。message 字段将生成文本中的换行替换为 <br />\n;subject 前缀 Re: 并引用原邮件主题;options.sendTo 引用原邮件发件人,options.threadId 引用原会话 ID,使草稿作为原邮件的回复出现。连接 Gmail OAuth2 凭证。
运行提示词 · 来源原文。Gmail - Create Draft 节点的 message 字段(HTML 转换)
={{ $json.text.replace(/\n/g, "<br />\n") }}运行提示词 · 来源原文。Gmail - Create Draft 节点的 subject 字段
=Re: {{ $('Gmail trigger').item.json.headers.subject }}运行提示词 · 来源原文。Gmail - Create Draft 节点的 options.sendTo 字段
={{ $('Gmail trigger').item.json.headers.from }}运行提示词 · 来源原文。Gmail - Create Draft 节点的 options.threadId 字段
={{ $('Gmail trigger').item.json.threadId }}
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限
这一段是提示词,页面不会在这里插入广告。
在 n8n 中导入模板 4870,按步骤连接 Gmail OAuth2 与 OpenAI API 凭证,确认标签名称与轮询间隔,再激活工作流。首次运行建议先用单封测试邮件验证语言检测与草稿生成结果。
激活前务必在 Gmail 中创建并应用目标标签;日语/英语提示词中的 [INSERT CLIENT NAME]、[INSERT YOUR COMPANY NAME]、[INSERT YOUR NAME] 需替换为实际信息或改为变量引用。
来源
Automated multilingual Gmail draft reply with OpenAI GPT-4o · henry · n8n.io · 2025-06-11
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。