8
n8n 中文网amn8n.com

多语言 Gmail 草稿自动回复

高级

这是一个Support, AI领域的自动化工作流,包含 16 个节点。主要使用 If, Gmail, Switch, GmailTrigger, ChainLlm 等节点,结合人工智能技术实现智能自动化。 使用 OpenAI GPT-4o 自动生成多语言 Gmail 草稿回复

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "OskjNtIb2AnxHXP2",
  "meta": {
    "instanceId": "1af8a0dc0d2f537b7c08209af728c271b5a03806bdf309bedf99d668f2608ee6",
    "templateCredsSetupCompleted": true
  },
  "name": "使用OpenAI GPT-4o在n8n中实现多语言Gmail草稿自动回复",
  "tags": [
    {
      "id": "UXY9NrpVC8pjYHmK",
      "name": "n8n Template",
      "createdAt": "2025-06-05T07:41:37.020Z",
      "updatedAt": "2025-06-05T07:41:37.020Z"
    }
  ],
  "nodes": [
    {
      "id": "579d54f2-8c04-4624-890a-c432d96f3911",
      "name": "如果需要回复",
      "type": "n8n-nodes-base.if",
      "position": [
        1500,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "53849246-ad32-4845-9976-9f9688f5a6f2",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.needsReply }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "526ab96e-bf2a-44f5-9e1b-3b1a10b5f55b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        0
      ],
      "parameters": {
        "width": 444,
        "height": 434,
        "content": "### Gmail触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "7289a14b-225e-4399-aa6c-cb56158f450d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        0
      ],
      "parameters": {
        "width": 576,
        "height": 577,
        "content": "### 评估需要回复的邮件内容"
      },
      "typeVersion": 1
    },
    {
      "id": "d10724dd-406c-4143-9c22-2c3ecd45e6be",
      "name": "Gmail - 创建草稿",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2760,
        160
      ],
      "webhookId": "a39b80e1-12c5-4569-aa46-63a2c2bd2d13",
      "parameters": {
        "message": "={{ $json.text.replace(/\\n/g, \"<br />\\n\") }}",
        "options": {
          "sendTo": "={{ $('Gmail trigger').item.json.headers.from }}",
          "threadId": "={{ $('Gmail trigger').item.json.threadId }}"
        },
        "subject": "=Re: {{ $('Gmail trigger').item.json.headers.subject }}",
        "resource": "draft",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "2pW13S2GyP5GCdoP",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "b805dfdb-a68e-458f-9af9-8a9e773a951d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2660,
        0
      ],
      "parameters": {
        "width": 326,
        "height": 395,
        "content": "### 在对话中创建草稿"
      },
      "typeVersion": 1
    },
    {
      "id": "cbb5c6a6-a445-474b-890f-54d1a546c28a",
      "name": "基于邮件语言的切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        1840,
        200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Japanese version",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b9788587-ad2a-4d44-bf01-f31c9412a48d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.message_language }}",
                    "rightValue": "Japanese"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "English version",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "429c0f4a-b5f8-4730-9609-40fe20acd496",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.message_language }}",
                    "rightValue": "English"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": 1
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "a720280e-7c5f-4f83-ad2e-b13572cba762",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        0
      ],
      "parameters": {
        "width": 813,
        "height": 740,
        "content": "### 生成回复"
      },
      "typeVersion": 1
    },
    {
      "id": "a107790b-f883-469e-8763-61ec92bf1d8e",
      "name": "为日本客户生成邮件",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2080,
        160
      ],
      "parameters": {
        "text": "=Subject: {{ $('Gmail trigger').item.json.subject }}\nMessage: {{ $('Gmail trigger').item.json.textAsHtml }}",
        "messages": {
          "messageValues": [
            {
              "message": "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.\nEnsure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner.\nDo not make things up.\n\nDetailed instructions:\n- Be concise and maintain a business tone (desu-masu).\n- Follow the following content \n[INSERT CLIENT NAME] 様\nお世話になっております。\n株式会社 [INSERT YOUR COMPANY NAME] の[INSERT YOUR NAME]です。\n\nBODY (main content)\n\n引き続き、何卒どうぞ宜しくお願いいたします。\n\n- When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by \" - - - - - - - OR - - - - - - - \"\n- If you don't know an answer, you can leave placeholders like \"[YOUR_ANSWER_HERE]\".\n- Don't use any special formatting, only plain text.\n- Make sure each request is separated with a new line break\n- Reply in the same language as the inbound email."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.4
    },
    {
      "id": "a548fcdd-1f5e-4a75-b136-07ecf4e96d3d",
      "name": "为英语客户生成邮件回复",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2080,
        440
      ],
      "parameters": {
        "text": "=Subject: {{ $('Gmail trigger').item.json.subject }}\nMessage: {{ $('Gmail trigger').item.json.textAsHtml }}",
        "messages": {
          "messageValues": [
            {
              "message": "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.\nEnsure that the reply is suitable for a professional email setting and addresses the topic in a clear, structured, and detailed manner.\nDo not make things up.\n\nDetailed instructions:\n- Be concise and maintain a business casual tone.\n- Start with \"Dear,\", and end with \"Best regards,\"\n- When replying to yes-no questions, draft 2 responses: one affirmative and one negative separated by \" - - - - - - - OR - - - - - - - \"\n- If you don't know an answer, you can leave placeholders like \"[YOUR_ANSWER_HERE]\".\n- Don't use any special formatting, only plain text.\n- Reply in the same language as the inbound email."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.4
    },
    {
      "id": "dcdf44aa-b313-4a22-ae45-0774e5a85add",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 941,
        "content": "## 使用OpenAI GPT-4o在n8n中实现多语言Gmail草稿自动回复"
      },
      "typeVersion": 1
    },
    {
      "id": "323eb990-e7c4-4495-811a-a3c5b26c27f0",
      "name": "Gmail触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        740,
        220
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": ""
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "2pW13S2GyP5GCdoP",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1659ef58-d317-4260-99a8-f1de50d50839",
      "name": "OpenAI GPT-4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1140,
        420
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {
          "temperature": 0,
          "responseFormat": "json_object"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "8cWUJS0NExv35YHi",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "aeb51aac-0706-4a0e-8a21-cc09147a6e87",
      "name": "评估邮件是否需要回复并识别语言",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1140,
        220
      ],
      "parameters": {
        "prompt": "=Subject: {{ $json.subject }}\nMessage:\n{{ $json.textAsHtml }} ",
        "messages": {
          "messageValues": [
            {
              "message": "Your task is to :\n- identify the language of the message and set the value to field \"message_language\" : \"English\", \"Japanese\" or \"Other\"\n- assess if the message requires a response and set the value to field \"needsReply\" : true if it does, false otherwise.\nReturn in JSON format.\nMarketing emails don't require a response."
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "7e8a17a4-fc57-4f8f-9755-3984547bfcce",
      "name": "解析器结果",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1300,
        420
      ],
      "parameters": {
        "jsonSchema": "={\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"needsReply\": {\n        \"type\": \"boolean\"\n      },\n      \"message_language\": {\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\"needsReply\", \"message_language\"]\n  }\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "79600a11-8038-48d7-a7a5-5c0ffdb6d412",
      "name": "OpenAI GPT-4o - 英语版",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2100,
        580
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8cWUJS0NExv35YHi",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e0e0ef36-5a52-4d77-ba51-270693ce893f",
      "name": "OpenAI GPT-4o - 日语版",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2060,
        300
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8cWUJS0NExv35YHi",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d9b8e365-5baa-47e6-bafb-8b138266a6f7",
  "connections": {
    "Gmail trigger": {
      "main": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o": {
      "ai_languageModel": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parser Result": {
      "ai_outputParser": [
        [
          {
            "node": "Assess if a message needs a reply and identify the language",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "If Needs Reply": {
      "main": [
        [
          {
            "node": "Switch based on email language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT 4o - For English": {
      "ai_languageModel": [
        [
          {
            "node": "Generate email reply for an English client",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o - for Japanese": {
      "ai_languageModel": [
        [
          {
            "node": "Generate email for a Japanese client",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Switch based on email language": {
      "main": [
        [
          {
            "node": "Generate email for a Japanese client",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate email reply for an English client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate email for a Japanese client": {
      "main": [
        [
          {
            "node": "Gmail - Create Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate email reply for an English client": {
      "main": [
        [
          {
            "node": "Gmail - Create Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assess if a message needs a reply and identify the language": {
      "main": [
        [
          {
            "node": "If Needs Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客户支持, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类2
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流