8
n8n 中文网amn8n.com

多部门支持机器人 - 斜杠命令、Pinecone与Telegram

高级

这是一个Support Chatbot, AI RAG领域的自动化工作流,包含 52 个节点。主要使用 Switch, Postgres, Telegram, GoogleDrive, Agent 等节点。 集成斜杠命令、Pinecone和Telegram的多部门支持机器人

前置要求
  • PostgreSQL 数据库连接信息
  • Telegram Bot Token
  • Google Drive API 凭证
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "10695d6c896719a133e4565c83ff18ae1c33cae9d0ca63f232efd9b2ddd0b904"
  },
  "nodes": [
    {
      "id": "169a4b72-f521-4804-8707-4ae76d3d0c44",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        320,
        1180
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35a9494a-ca0e-43da-bd95-fe07dd7806ca",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/ReturnPolicy"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "afb17bcd-17e4-4e68-96b3-2bbb6cd4fb82",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/TechSupport"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8cb762a5-51de-4dba-b8fc-9a68f9ec06a1",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "/billing"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ed19a160-1fb9-4d93-92b8-9b8a1368567d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$('Telegram Trigger').item.json.message.text}}",
                    "rightValue": "asakjlkadjclsdja"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": 3
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "2655b5df-6785-439e-9783-618a06c8784b",
      "name": "退货政策",
      "type": "n8n-nodes-base.telegram",
      "position": [
        620,
        1000
      ],
      "webhookId": "c62a1217-aa18-4a94-a05a-abc3442877e1",
      "parameters": {
        "text": "lets talk return policy",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "forceReply": {
          "force_reply": false
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "32410d0b-32a5-4393-b82f-556faca60cae",
      "name": "技术咨询",
      "type": "n8n-nodes-base.telegram",
      "position": [
        760,
        1180
      ],
      "webhookId": "c62a1217-aa18-4a94-a05a-abc3442877e1",
      "parameters": {
        "text": "lets talk technical",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0b0128f0-68fe-463e-add2-17020aee9ac1",
      "name": "账单",
      "type": "n8n-nodes-base.telegram",
      "position": [
        760,
        1380
      ],
      "webhookId": "c62a1217-aa18-4a94-a05a-abc3442877e1",
      "parameters": {
        "text": "lets talk billing",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c70d33d-88a8-47de-9285-87024c0252df",
      "name": "Pinecone Vector Store3",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        2360
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "billing"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d46f0633-3bd1-49e0-8b24-2a752032f727",
      "name": "Google Drive 触发器",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        2560
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "id",
          "value": "1Ts06s4RSssNx8tfIqTbjFeWZL1Dno_xJ"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fe91a6d9-f4ed-4592-9df6-25a73aafdc1d",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        2560
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "af0b032a-b100-48c6-9740-e9d5b62d336d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        2300
      ],
      "parameters": {
        "width": 960,
        "height": 620,
        "content": "## 账单上传"
      },
      "typeVersion": 1
    },
    {
      "id": "ee6c5ee5-74c3-4be1-91fe-7f62fa46bce2",
      "name": "Embeddings Cohere3",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        2580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fb0fb46c-a04f-451a-9793-822fa42049e9",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        2600
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bed21d2d-e317-45cb-9d07-a9d8a27fa45d",
      "name": "字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        2780
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9194bfa2-e59a-44e9-890a-ef354fcda7fc",
      "name": "Pinecone Vector Store4",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        3020
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "tech ques"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c693ae06-a195-4d6a-8053-3578a9d718ac",
      "name": "Google Drive Trigger1",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        3220
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1Tz-YkUC4dN85YyBeb-MPmexomRPx2AtN",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Tz-YkUC4dN85YyBeb-MPmexomRPx2AtN",
          "cachedResultName": "talk technical"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a0bcf807-5131-42ea-bfca-274766d0932c",
      "name": "下载文件1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        3220
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "c59e303f-a3ba-4250-b3ca-40bde6c3a6df",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        2980
      ],
      "parameters": {
        "width": 1000,
        "height": 600,
        "content": "## 技术问题"
      },
      "typeVersion": 1
    },
    {
      "id": "e4e79010-96cb-4e83-aab4-096af8996e1d",
      "name": "Embeddings Cohere4",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        3240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d845fa2f-121e-44ff-8936-e9bac8b834a7",
      "name": "默认数据加载器1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        3260
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5a1914a3-830c-442e-88a7-2971ff56834e",
      "name": "Character Text Splitter1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        3440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "696b1cd1-da5f-4234-8efe-abc06138ac97",
      "name": "Pinecone Vector Store5",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        640,
        3880
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "pineconeNamespace": "return policy"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "53bc8499-b513-41bc-8cd4-098284b3dabe",
      "name": "Google Drive Trigger2",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        180,
        3880
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "hour": 1,
              "mode": "everyMonth"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1bomT-vMmuKgjl_y6XTgwfCUvPMyq2iZf",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1bomT-vMmuKgjl_y6XTgwfCUvPMyq2iZf",
          "cachedResultName": "return policy"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5e07b0c2-8d71-40c3-a3c9-4fc772b30218",
      "name": "下载文件2",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        400,
        3880
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "ca734c58-dc19-40e8-933f-dd68f023ae02",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        3860
      ],
      "parameters": {
        "width": 980,
        "height": 580,
        "content": "## 退货政策"
      },
      "typeVersion": 1
    },
    {
      "id": "fc503485-7187-44df-ba80-d1976dcff6b1",
      "name": "Embeddings Cohere5",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        620,
        4100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "534c6970-b519-4e51-acba-bda3f85ea8b8",
      "name": "默认数据加载器2",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        740,
        4120
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "95ff3aca-f1a8-4f52-95c1-74412d5cabb8",
      "name": "Character Text Splitter2",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        840,
        4300
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "95de976e-cb31-48d7-a160-dbc1f50ae83a",
      "name": "Telegram触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        180,
        580
      ],
      "webhookId": "e4985641-ce69-4278-9f65-c6e498d05ee9",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d0c5aee1-8e14-4400-8686-286800c35dd0",
      "name": "发送短信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        180
      ],
      "webhookId": "5e468b80-2389-42c3-aa04-097ed524a6fc",
      "parameters": {
        "text": "to connect to specific reply with their key:\nfor Billing: /billing\nfor Return Policy: /ReturnPolicy\nfor Tech Support: /TechSupport",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2f5d1808-9c59-444c-ae26-252840bef07d",
      "name": "开关1",
      "type": "n8n-nodes-base.switch",
      "position": [
        840,
        560
      ],
      "parameters": {
        "mode": "expression",
        "output": "={{ \n  $('Telegram Trigger').item.json.message.text === \"/start\" ? 0 :\n  $('Telegram Trigger').item.json.message.text === \"/end\" ? 3 :\n  ($json.active === \"true\" || $json.active === true)\n    ? ($json.department != null ? 2 : 4)\n    : 1\n}}\n",
        "numberOutputs": 5
      },
      "typeVersion": 3.2
    },
    {
      "id": "7cd8a4b2-0133-4f67-a99c-fb213e1fe114",
      "name": "发送文本消息4",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1560,
        380
      ],
      "webhookId": "ecee3aa8-e019-46c5-8020-9b8e6e59a7d8",
      "parameters": {
        "text": "reply with /start to get options. \nTo end chat reply with /end",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9cae49e0-00f6-46b4-947a-a5373afd2db0",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1300,
        580
      ],
      "parameters": {
        "text": "={{ $('Telegram Trigger').item.json.message.text }}",
        "options": {
          "systemMessage": "=You are a helpful assistant\n\n## job\n-your  job  is guide user on respective department\n- department: {{ $json.department }}\n\n## source\n- you can access data from respective vector store connected as tool\n## note\n- if user is on a department let say billing and asks questions for tech support respectully decline and ask user to end conversation with current department usind /end commant and start again\n- be precise in answers\n\n## signoff as john wick"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "2f847e8b-5284-44f7-9c02-51b21afd6cd4",
      "name": "Pinecone Vector Store6",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1300,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "return policy"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for return policy."
      },
      "typeVersion": 1.3
    },
    {
      "id": "c479a97b-c4e3-4b2c-a81a-356121ad33ad",
      "name": "Embeddings Cohere6",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1400,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f657fd84-8f76-4666-ad5e-d31cd9e94a6b",
      "name": "OpenRouter 聊天模型3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1060,
        800
      ],
      "parameters": {
        "model": "deepseek/deepseek-chat-v3-0324:free",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "5fe9737c-3017-47c2-b6b6-aa432b7a40d8",
      "name": "Simple Memory3",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1180,
        800
      ],
      "parameters": {
        "sessionKey": "={{ $json.user_id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1df2223b-10b0-4188-a096-0eab3ff7fbc3",
      "name": "Pinecone Vector Store7",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1600,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "tech ques"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for technical questions."
      },
      "typeVersion": 1.3
    },
    {
      "id": "0cfb6c6d-a8b7-431b-9eaf-14b2c5271a78",
      "name": "Embeddings Cohere7",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1680,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bf4ab1b4-6759-432a-92f7-12e126e58f51",
      "name": "Pinecone Vector Store8",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1900,
        820
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {
          "pineconeNamespace": "billing"
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n-proj",
          "cachedResultName": "n8n-proj"
        },
        "toolDescription": "vectore store for billing data."
      },
      "typeVersion": 1.3
    },
    {
      "id": "5df4670c-f094-4473-a486-d0afdb2aa403",
      "name": "Embeddings Cohere8",
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "position": [
        1980,
        1000
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9382e126-fc0d-4b06-a729-de2a43da77cb",
      "name": "发送短信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1960,
        580
      ],
      "webhookId": "cefa8b41-fc7c-4c5a-b2be-fc820b766610",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8b2596d8-9f34-4ac3-8f26-bcecb2317f13",
      "name": "执行 SQL 查询",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -580,
        1080
      ],
      "parameters": {
        "query": "CREATE TABLE tg_user_sessions (\n    user_id BIGINT PRIMARY KEY,\n    department TEXT,\n    active BOOLEAN DEFAULT FALSE,\n    last_updated TIMESTAMP DEFAULT NOW()\n);\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "f3bb4192-e412-4008-9d40-d8144978a8b3",
      "name": "执行 SQL 查询1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        400,
        580
      ],
      "parameters": {
        "query": "INSERT INTO tg_user_sessions (user_id, active)\nSELECT {{ $json.message.from.id }}, FALSE\nWHERE NOT EXISTS (\n  SELECT 1 FROM tg_user_sessions WHERE user_id = {{ $json.message.from.id }}\n);\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "7b6b801f-5228-4b22-a9ca-d5190aef5d8a",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        1020
      ],
      "parameters": {
        "width": 320,
        "height": 220,
        "content": "## 仅用于创建表"
      },
      "typeVersion": 1
    },
    {
      "id": "ffb5945c-0faa-478d-a4c0-956f92ba6eca",
      "name": "从表中选择行",
      "type": "n8n-nodes-base.postgres",
      "position": [
        620,
        580
      ],
      "parameters": {
        "limit": 1,
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tg_user_sessions",
          "cachedResultName": "tg_user_sessions"
        },
        "where": {
          "values": [
            {
              "value": "={{ $('Telegram Trigger').item.json.message.from.id }}",
              "column": "user_id"
            }
          ]
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "options": {},
        "operation": "select"
      },
      "typeVersion": 2.6
    },
    {
      "id": "56fb3d1c-f76e-4c18-bcb8-1e2eb756945b",
      "name": "执行 SQL 查询2",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1560,
        1180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = FALSE,\n    department = NULL\nWHERE user_id = {{ $('Telegram Trigger').item.json.message.from.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "92887eea-2a12-4506-82f9-a8df748d4d0e",
      "name": "发送文本消息2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2280,
        1180
      ],
      "webhookId": "4c4348e9-90c1-4666-8fc1-3a0c5b4f7ab2",
      "parameters": {
        "text": "to continue chat again send /start",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a0008611-10cb-4f0f-ba48-2e6fbf5bb601",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 2680,
        "height": 1740,
        "content": "## 主机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "10d2f6c6-a1d3-4282-85ee-f7463ccb7e3d",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        620
      ],
      "parameters": {
        "width": 380,
        "height": 260,
        "content": "## 工作状态"
      },
      "typeVersion": 1
    },
    {
      "id": "0dea67af-08b8-4f0e-a748-ce73e226e865",
      "name": "退货政策1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        840,
        1000
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Return Policy'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "282e945a-193b-4ea3-a8de-5bec72c4acfd",
      "name": "技术问题",
      "type": "n8n-nodes-base.postgres",
      "position": [
        980,
        1180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Tech Support'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "862c87ae-abf8-42a7-8f9f-de637f66c4c5",
      "name": "账单1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        980,
        1380
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = 'Billing'\nWHERE user_id ={{ $json.result.chat.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "26744059-ee41-42e5-8acd-83743612ef63",
      "name": "执行 SQL 查询3",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1780,
        180
      ],
      "parameters": {
        "query": "UPDATE tg_user_sessions\nSET active = TRUE,\n    department = NULL\nWHERE user_id = {{ $('Telegram Trigger').item.json.message.from.id }};\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "2c8f329a-8c77-420b-b815-d3d75fdf40b5",
      "name": "发送文本消息3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        440,
        1500
      ],
      "webhookId": "b3e36a5a-d2c8-4fe5-b6bb-56bfe084250c",
      "parameters": {
        "text": "provide correct dpt|for Billing: /billing for Return Policy: /ReturnPolicy for Tech Support: /TechSupport",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "return policy",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "talk technical",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "billing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a text message4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Execute a SQL query2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "billing": {
      "main": [
        [
          {
            "node": "billing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "return policy": {
      "main": [
        [
          {
            "node": "return policy1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file1": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file2": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory3": {
      "ai_memory": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "talk technical": {
      "main": [
        [
          {
            "node": "tech questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Execute a SQL query1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere3": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere4": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere5": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere6": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store6",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere7": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store7",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere8": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store8",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store3",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "Execute a SQL query3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store4",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader2": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store5",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query1": {
      "main": [
        [
          {
            "node": "Select rows from a table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query2": {
      "main": [
        [
          {
            "node": "Send a text message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger1": {
      "main": [
        [
          {
            "node": "Download file1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger2": {
      "main": [
        [
          {
            "node": "Download file2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store6": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store7": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store8": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter2": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader2",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Select rows from a table": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客服机器人, AI RAG 检索增强

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流