8
n8n 中文网amn8n.com

使用GPT-4o、Dumpling AI和LangChain Agent自动回复Gmail咨询

中级

这是一个Support, AI领域的自动化工作流,包含 10 个节点。主要使用 Filter, GmailTool, GmailTrigger, Agent, OpenAi 等节点,结合人工智能技术实现智能自动化。 使用GPT-4o、Dumpling AI和LangChain Agent自动回复Gmail咨询

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "uQTqLH5At9PZOy2g",
  "meta": {
    "instanceId": "a1ae5c8dc6c65e674f9c3947d083abcc749ef2546dff9f4ff01de4d6a36ebfe6",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 GPT-4o、Dumpling AI 和 LangChain Agent 自动回复 Gmail 咨询",
  "tags": [],
  "nodes": [
    {
      "id": "149c7dd9-9f5f-4c5b-8342-7c907eb52402",
      "name": "监控 Gmail 的新收邮件",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -2300,
        -340
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "j70r3RTMED1pgN3R",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8a0de384-9028-47e3-86e5-b5bf6476ae0c",
      "name": "使用 GPT-4o 分类邮件类型",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -2080,
        -340
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Classify the following email content. Determine if it is an enquiry.\nIf it is an enquiry, return only this word: enquiry\nIf it is not an enquiry, return only this word: false\nDo not explain or add any other text. Only return the result.\nHere is the email body: {{ $json.snippet }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "fdhWALG84tBLgSZT",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "57756cd3-9009-4189-8cba-e2edba87554f",
      "name": "仅当邮件是咨询时继续处理",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1704,
        -340
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6019006-0980-4cd6-8e5d-3f618fbca13a",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.content }}",
              "rightValue": "enquiry"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "64e851b8-7ff1-4b4c-9828-7c764594f1ea",
      "name": "GPT-4o 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1484,
        -120
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "fdhWALG84tBLgSZT",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2957c6ad-5e7b-4692-a96f-5c4fb5b8203c",
      "name": "记忆缓冲区(过去10次交互)",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1364,
        -120
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "9e8617f1-cd89-4de5-9d44-ded155779745",
      "name": "Dumpling AI Agent - 搜索相关信息",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        -1244,
        -120
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/agents/generate-completion",
        "method": "POST",
        "jsonBody": "={\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\":\"{{ $('Watch Gmail for New Incoming Emails').item.json.snippet }}\"\n    }\n  ],\n  \"agentId\": \"a88a9b6c-1578-4da2-800b-561327367713\",\n  \"parseJson\": \"True\"\n  }",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "5CBvzXCLjwWzCJRE",
          "name": "n8n_integration"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "da474406-a6e3-427d-b21b-3e7e00ebe910",
      "name": "通过 Gmail 发送邮件回复",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -1124,
        -120
      ],
      "webhookId": "b39f740b-77d1-426a-a07a-186a9ff0c1af",
      "parameters": {
        "sendTo": "",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "j70r3RTMED1pgN3R",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "03882650-9272-43c3-b1bc-15adae456881",
      "name": "LangChain Agent 处理回复逻辑",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1392,
        -340
      ],
      "parameters": {
        "text": "={{ $('Watch Gmail for New Incoming Emails').item.json.snippet }}",
        "options": {
          "systemMessage": "You are a helpful assistant, use the search for information tool to search for users information.\n\nuse Gmail tool to send email"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "52bb3b65-0b7f-4206-87c9-1f91997a44dd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1500,
        -560
      ],
      "parameters": {
        "width": 480,
        "height": 240,
        "content": "### ✉️ 便签2:网站爬取、邮件生成和发送"
      },
      "typeVersion": 1
    },
    {
      "id": "3a6df2e9-1d1a-4cab-889c-c323f876b98f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2320,
        -540
      ],
      "parameters": {
        "width": 540,
        "height": 220,
        "content": "### 便签1:Apollo 线索获取和联系人爬取"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0f1d6a0b-eb13-4e1a-be9e-3f22eb17e66e",
  "connections": {
    "GPT-4o Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "LangChain Agent Handles Reply Logic",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Response via Gmail": {
      "ai_tool": [
        [
          {
            "node": "LangChain Agent Handles Reply Logic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Classify Email Type with GPT-4o": {
      "main": [
        [
          {
            "node": " Only Proceed if Email is an Enquiry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LangChain Agent Handles Reply Logic": {
      "main": [
        []
      ]
    },
    "Watch Gmail for New Incoming Emails": {
      "main": [
        [
          {
            "node": "Classify Email Type with GPT-4o",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " Only Proceed if Email is an Enquiry": {
      "main": [
        [
          {
            "node": "LangChain Agent Handles Reply Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Memory Buffer (Past 10 Interactions)": {
      "ai_memory": [
        [
          {
            "node": "LangChain Agent Handles Reply Logic",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Dumpling AI Agent – Search for Relevant Info": {
      "ai_tool": [
        [
          {
            "node": "LangChain Agent Handles Reply Logic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量10
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流