8
n8n 中文网amn8n.com

带有 RAG、GPT-4o 和 Telegram 的客户支持和潜在客户收集聊天机器人

中级

这是一个Support Chatbot领域的自动化工作流,包含 14 个节点。主要使用 TelegramTool, Agent, GoogleSheetsTool, ChatTrigger, LmChatOpenAi 等节点。 使用 RAG、GPT-4o、Sheets 和 Telegram 的客户支持和潜在客户收集聊天机器人

前置要求
  • Telegram Bot Token
  • Google Sheets API 凭证
  • OpenAI API Key
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "gH7TgPzRzkONOivn",
  "meta": {
    "instanceId": "a244e08ca65e768d1cee097a486ef066f1968b077e055f21a34efe4e78c40e76",
    "templateCredsSetupCompleted": true
  },
  "name": "带有 RAG、GPT-4o 和 Telegram 的客户支持和潜在客户收集聊天机器人",
  "tags": [
    {
      "id": "AOZlNztgqiOQKd6j",
      "name": "n8n Creators",
      "createdAt": "2025-09-28T11:02:15.227Z",
      "updatedAt": "2025-09-28T11:02:15.227Z"
    }
  ],
  "nodes": [
    {
      "id": "0cd4236d-fa91-405f-bbd9-a816098202f5",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "73cc5ea3-7518-488b-955e-df5e78ee12b3",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "da8b3e29-20c2-4f16-a01e-b7ae45bb0efa",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        384,
        0
      ],
      "parameters": {
        "options": {
          "systemMessage": "=## Role:\nYou are a friendly assistant for a company named **[INSERT_YOUR_COMPANY_NAME_HERE]**.\n\n## Task:\nYou answer questions about the business.\n\n## Details:\nYou have access to various tools, which you use correctly.\n\n## Tools:\n- **Company Q&A**  \n  Use this tool to answer questions with knowledge about the company.\n\n- **Google Sheets Agentic Tool**  \n  Use this tool to store contact information such as name, email, interested in and phone number.\n\n- **Telegram Agentic Tool**\n  Use this tool to send a notification with the user's contact information and a summary of the conversation.\n\nAfter a customer asks about opening hours, products, location, or business information, ask them for their name, email, specific interests and phone number."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "33f3d156-d41d-44e2-af46-d29cb9fe7832",
      "name": "对话记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        368,
        224
      ],
      "parameters": {
        "contextWindowLength": 12
      },
      "typeVersion": 1.3
    },
    {
      "id": "d205da7f-7acc-4709-9878-331a70218ce7",
      "name": "公司问答",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        432,
        400
      ],
      "parameters": {
        "description": "提供与公司相关的答案。"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ab524ffa-cce1-4dee-938e-fbdee31b353c",
      "name": "Pinecone 向量存储(公司知识库)",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        384,
        560
      ],
      "parameters": {
        "options": {
          "pineconeNamespace": "Q&A"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "company",
          "cachedResultName": "company"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "lJsLCGEJnS6Ij994",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "28bd6bd0-bedc-47a0-b345-a18f7d2e7831",
      "name": "生成嵌入(OpenAI)",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        464,
        704
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "1rHbxq7xrWlOZ6zj",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "98dcb3ff-693a-47d3-9031-502dfe49becf",
      "name": "触发器 – 如何发布",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -144
      ],
      "parameters": {
        "width": 256,
        "height": 304,
        "content": "## 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "55791e26-65d8-4af8-ad8b-d321044583de",
      "name": "AI 代理 – 流程",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -240
      ],
      "parameters": {
        "width": 736,
        "height": 608,
        "content": "## AI 代理"
      },
      "typeVersion": 1
    },
    {
      "id": "d71bbe39-776a-465d-a463-84d6fcaa6f70",
      "name": "RAG 数据库 – 设置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        384
      ],
      "parameters": {
        "width": 656,
        "height": 592,
        "content": "## RAG 数据库"
      },
      "typeVersion": 1
    },
    {
      "id": "f9e798e4-771f-47f6-8fc6-87379e5c388c",
      "name": "发送潜在客户到 Telegram",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        624,
        224
      ],
      "webhookId": "3d40f03b-9560-4c2a-b64d-bca5736f148b",
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "[INSERT_YOUR_CHAT_ID]",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "xV3Qf8JA7DE2hn9V",
          "name": "Telegram test"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f045418b-84c6-4476-8a06-0538fe7eb191",
      "name": "保存潜在客户到 Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        768,
        224
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Name', ``, 'string') }}",
            "Email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}",
            "Phone": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone', ``, 'string') }}",
            "Interested in": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Interested_in', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Interested in",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Interested in",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ccKn1a35BDW3Vqe6cCjoiWlDTl5XIY48PUFYUREVZeM/edit?usp=drivesdk",
          "cachedResultName": "NovaCore Solutions Leads"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "3CWHe6cifmQtahz8",
          "name": "SmartCamp.AI Google Sheets"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c08fa915-6a60-453b-a663-058c92c1355f",
      "name": "公司应答模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        672,
        608
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "1rHbxq7xrWlOZ6zj",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54007e6f-bf76-4811-950e-b2bd316d75c1",
      "name": "主聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        224,
        224
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "1rHbxq7xrWlOZ6zj",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "guide-sticky-001",
      "name": "模板指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        -160
      ],
      "parameters": {
        "width": 736,
        "height": 736,
        "content": "## 模板指南(概述、先决条件和自定义)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d216f344-bdc5-4b44-916f-8eaec439de1f",
  "connections": {
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Company Q&A": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Main Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Lead to Telegram": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Company Answering Model": {
      "ai_languageModel": [
        [
          {
            "node": "Company Q&A",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Save Lead to Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Embeddings (OpenAI)": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store (Company KB)",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store (Company KB)": {
      "ai_vectorStore": [
        [
          {
            "node": "Company Q&A",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客服机器人

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流