8
n8n 中文网amn8n.com

Telegram AI支持聊天机器人(多模态输入)

高级

这是一个Support Chatbot, AI RAG领域的自动化工作流,包含 51 个节点。主要使用 If, Set, Code, Switch, Telegram 等节点。 使用GPT-4和Supabase RAG创建多模态Telegram支持机器人

前置要求
  • Telegram Bot Token
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • PostgreSQL 数据库连接信息
  • Supabase URL 和 API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "pE6f3n6i6GUmSTgE",
  "meta": {
    "instanceId": "9f0f18185ff67394d162d12e4c08dd0fcafc744c1f810dda24cdefd72c8a1df1",
    "templateCredsSetupCompleted": true
  },
  "name": "Telegram AI 支持聊天机器人(多模态输入)",
  "tags": [
    {
      "id": "Hsf1ZjQwJBHNaX1m",
      "name": "telegram",
      "createdAt": "2025-06-30T13:02:48.515Z",
      "updatedAt": "2025-06-30T13:02:48.515Z"
    },
    {
      "id": "b0xPsiva0fSoITZd",
      "name": "Ai agent",
      "createdAt": "2025-06-30T13:02:48.451Z",
      "updatedAt": "2025-06-30T13:02:48.451Z"
    },
    {
      "id": "fvM6EUbE34rR2wmT",
      "name": "customer support",
      "createdAt": "2025-06-30T13:02:48.420Z",
      "updatedAt": "2025-06-30T13:02:48.420Z"
    },
    {
      "id": "w2QpLU5syMOj79qo",
      "name": "chatbot",
      "createdAt": "2025-06-30T13:02:48.473Z",
      "updatedAt": "2025-06-30T13:02:48.473Z"
    }
  ],
  "nodes": [
    {
      "id": "2bcc338a-d519-42dd-bffd-9b5854b3a456",
      "name": "Telegram触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        860,
        489.5
      ],
      "webhookId": "5dfaa8fa-e242-4581-9ba4-a8dd27fdb5cd",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ebc22166-b749-42c7-9d91-9fef170c6b65",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3896,
        1156.5
      ],
      "webhookId": "3f88dafc-b70c-4241-9960-d02d8e5c76d4",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "343b5290-d805-4136-a609-b12025df5339",
      "name": "下载音频",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2840,
        500
      ],
      "webhookId": "d3e9d36d-6402-45d6-9f56-5886e616f9fa",
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8d5bd08c-5b59-4bff-97b1-ffca75262d1b",
      "name": "翻译为文本",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3060,
        500
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "translate"
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "3def7806-cf50-4fc8-a2c6-ea966cd0bd4e",
      "name": "下载 PDF",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1050
      ],
      "webhookId": "c9a95ea8-9864-4bfe-9bc4-36ad917741ec",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "29624835-cc63-489f-8913-ece65ecf46f2",
      "name": "下载图像",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        1250
      ],
      "webhookId": "38d23405-f59b-4dbc-a69e-b1101e198908",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "11755226-785d-4719-9d75-d82518ed615b",
      "name": "修复 mimeType",
      "type": "n8n-nodes-base.code",
      "position": [
        2400,
        1250
      ],
      "parameters": {
        "jsCode": "for (const item of items) {\n  if (item.binary && item.binary['data']) {\n    const fileName = item.binary['data'].fileName || '';\n    const lowerName = fileName.toLowerCase();\n\n    if (lowerName.endsWith('.png')) {\n      item.binary['data'].mimeType = 'image/png';\n    } else if (lowerName.endsWith('.jpg') || lowerName.endsWith('.jpeg')) {\n      item.binary['data'].mimeType = 'image/jpeg';\n    } else if (lowerName.endsWith('.webp')) {\n      item.binary['data'].mimeType = 'image/webp';\n    }\n  }\n}\nreturn items;\n\n\n\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2d7fe3f6-d152-4b6d-8184-96f1073c73c6",
      "name": "下载照片",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        700
      ],
      "webhookId": "b4a21f4c-e6a6-4c83-9e8e-af73cb7cc96a",
      "parameters": {
        "fileId": "={{ $json.message.photo[0].file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "802f819c-9d11-4720-a63f-0d3bada509bf",
      "name": "修复 mimeType1",
      "type": "n8n-nodes-base.code",
      "position": [
        2400,
        700
      ],
      "parameters": {
        "jsCode": "for (const item of items) {\n  if (item.binary && item.binary['data']) {\n    const fileName = item.binary['data'].fileName || '';\n    const lowerName = fileName.toLowerCase();\n\n    if (lowerName.endsWith('.png')) {\n      item.binary['data'].mimeType = 'image/png';\n    } else if (lowerName.endsWith('.jpg') || lowerName.endsWith('.jpeg')) {\n      item.binary['data'].mimeType = 'image/jpeg';\n    } else if (lowerName.endsWith('.webp')) {\n      item.binary['data'].mimeType = 'image/webp';\n    } else if (lowerName.endsWith('.gif')) {\n      item.binary['data'].mimeType = 'image/gif';\n    }\n  }\n}\nreturn items;\n\n\n\n/** This is for jpeg. Delete later\nfor (const item of items) {\n  if (item.binary && item.binary['data']) {\n    item.binary['data'].mimeType = 'image/jpeg';\n  }\n}\nreturn items;\n**/\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e245a098-08ba-4cf1-a3aa-3134070016ae",
      "name": "照片转文本",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2620,
        700
      ],
      "parameters": {
        "text": "Describe the contents of this photo/image",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "resource": "image",
        "inputType": "base64",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "74df7c06-f07f-4504-a246-33665d355d70",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        1520,
        1350
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "95deb83e-1d69-46b6-92e3-59e667d698fe",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.is_supported }}",
              "rightValue": ""
            },
            {
              "id": "5d9924b8-b8e7-4640-9675-8123e1562fa8",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.reason }}",
              "rightValue": "supported_file_type"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "531826bd-e8ab-4e56-9f56-4e0dd8847c2f",
      "name": "下载电子表格",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1650
      ],
      "webhookId": "fa2ada79-935b-4ea4-9a0c-a452d13c7a0c",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6ffa7f95-c506-40ff-a320-f2b8b35db632",
      "name": "从 PDF 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1050
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "795a57de-78c6-44e8-a89b-a45c354988c9",
      "name": "从电子表格提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1650
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1
    },
    {
      "id": "f567e9a4-e043-4431-b574-b217b4fa2656",
      "name": "正在输入…",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1080,
        379
      ],
      "webhookId": "412793ca-7cad-4a84-acea-98debbbfa2ac",
      "parameters": {
        "chatId": "={{ $json.message.chat.id }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "67edb91b-880e-4542-88e7-fc7bde727a75",
      "name": "支持的文档文件类型",
      "type": "n8n-nodes-base.code",
      "position": [
        1300,
        1350
      ],
      "parameters": {
        "jsCode": "const supportedExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.json', '.xml'];\n\nreturn $input.all().map(item => {\n  // Try to extract file name from binary first, else fall back to message.document\n  const fileName = item.binary?.data?.fileName || item.json?.message?.document?.file_name || '';\n  const lowerName = fileName.toLowerCase();\n\n  const isSupported = supportedExtensions.some(ext => lowerName.endsWith(ext));\n\n  if (!isSupported) {\n    return {\n       json: {\n        is_supported: false,\n        reason: \"unsupported_file_type\",\n        message: '❌ The uploaded file type is not supported. Please submit one of the following formats: .jpg, jpeg, .png, .webp, .pdf, .doc, .docx, .xls, .xlsx, .json, .xml',\n        fileName: fileName || 'Unknown file'\n      }\n    };\n  }\n\n  // File is supported – pass it forward untouched\n  return {\n    ...item,\n    json: {\n      ...(item.json || {}),\n      is_supported: true,\n      reason: \"supported_file_type\"\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5c13b643-22c6-49cb-9055-54826f49fd13",
      "name": "分组相似文档",
      "type": "n8n-nodes-base.code",
      "position": [
        1740,
        1550
      ],
      "parameters": {
        "jsCode": "const results = [];\nfor (const item of $input.all()) {\nconst fileName = item.json?.fileName || item.json?.message?.document?.file_name || '';\nconst ext = fileName.toLowerCase().split('.').pop();\n\nlet type = 'unknown';\nif (['jpg', 'jpeg', 'png', 'webp'].includes(ext)) {\ntype = 'image';\n} else if (['pdf'].includes(ext)) {\ntype = 'pdf';\n} else if (['doc', 'docx'].includes(ext)) {\ntype = 'word document';\n} else if (['xls', 'xlsx'].includes(ext)) {\ntype = 'spreadsheet';\n} else if (['json'].includes(ext)) {\ntype = 'json';\n} else if (['xml'].includes(ext)) {\ntype = 'xml file'\n}\nitem.json.fileTypeCategory = type;\nresults.push(item);\n}\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "1923a439-9f1c-4df1-9360-a41250e61931",
      "name": "输入消息路由器",
      "type": "n8n-nodes-base.switch",
      "position": [
        1080,
        579
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fcb767ee-565e-4b56-a54e-6f97f739fc24",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c1016c40-f8f2-4e08-8ec8-5cdb88f5c87a",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Photo",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4f28ab72-33ae-45fa-b3ba-51cefe600434",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Document",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "47b17a80-c23f-4b7c-9761-f045715334f4",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.document }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "510a0800-4323-4372-9f8a-3b3c26d8a455",
      "name": "文档路由器",
      "type": "n8n-nodes-base.switch",
      "position": [
        1960,
        1487
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b688a3fb-8070-4506-9c9d-526d74c2605b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "PDF",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "157a49a2-d5fb-425d-bb23-6ac16bdc45a2",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "pdf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Word Document",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "41b0d6a4-89a7-4e3b-9e4a-00689def90aa",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "word document"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Spreadsheet",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "478f9497-7fc8-46e9-b834-22c78bbc7b05",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "spreadsheet"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "JSON",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d90c32c0-9d28-40d1-b11c-4fa9a14b7df5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "json"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "XML File",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4d4f7af7-ca8f-4a22-9af1-b3c93f51958f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.fileTypeCategory }}",
                    "rightValue": "xml file"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "8c04ffbb-9a63-4089-8877-c0c668eeabcc",
      "name": "下载 JSON",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        1850
      ],
      "webhookId": "a364075a-9edc-4624-b867-15710db87e8d",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "06a353d1-1ead-4973-aeff-4991ae2ca29f",
      "name": "从 JSON 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        1850
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1
    },
    {
      "id": "376ab859-3a6a-4f2d-80da-f0ab8c5149f6",
      "name": "下载 XML",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        2050
      ],
      "webhookId": "db40435f-f201-4156-aa2d-9c5285dabbe4",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a4c890b7-d858-42aa-9e60-746ce6b6d17b",
      "name": "从 XML 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2840,
        2050
      ],
      "parameters": {
        "options": {},
        "operation": "xml"
      },
      "typeVersion": 1
    },
    {
      "id": "d91df63b-926b-43f5-9846-14cdde235b8d",
      "name": "下载 Word 文档",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2180,
        1450
      ],
      "webhookId": "559f8f6c-743e-415a-bdbf-45360dd5f115",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "id": "WCLbjm37GUpYDc78",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8a4fecf9-c50e-44ce-a4ce-c60713805f71",
      "name": "文件转 Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2400,
        1450
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "b40a6b1f-0a8e-4788-ae3a-17138cf5918e",
      "name": "转换为文本 (convertapi.com)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2620,
        1450
      ],
      "parameters": {
        "url": "https://v2.convertapi.com/convert/docx/to/txt",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"Parameters\": [\n        {\n            \"Name\": \"File\",\n            \"FileValue\": {\n                \"Name\": \"{{ $('Download Word Document').item.binary.data.fileName }}\",\n                \"Data\": \"{{ $json.data }}\"\n            }\n        },\n        {\n            \"Name\": \"StoreFile\",\n            \"Value\": true\n        }\n    ]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "59fad9e4-dbfc-4f6b-bfad-156b821e78dd",
      "name": "下载文本",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2840,
        1450
      ],
      "parameters": {
        "url": "={{ $json.Files[0].Url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "914ab0ed-f102-4fa3-9db3-cf097b92c0ec",
      "name": "照片转文本1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2620,
        1250
      ],
      "parameters": {
        "text": "Describe the content of this image.",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "detail": "auto"
        },
        "resource": "image",
        "inputType": "base64",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "9f4e250c-fb80-4b96-a9c6-d4fd47382985",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        1280
      ],
      "parameters": {
        "color": 4,
        "width": 620,
        "height": 260,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "f38669dd-5f21-4bb6-9f4d-1768e629eb0e",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        440
      ],
      "parameters": {
        "width": 620,
        "height": 800,
        "content": "## ⚙️ 工作原理"
      },
      "typeVersion": 1
    },
    {
      "id": "ca3a50ef-8148-4bb7-810c-a14422791866",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        860,
        -160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5f8a25d8-a8bb-4b01-a7b0-7ad7d58ab0c9",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1080,
        -160
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "list",
          "value": "19mt-vKtgLTvoqhR8TgbN9eSyGIkrrBjqjWfj8EDlZpU",
          "cachedResultUrl": "https://docs.google.com/document/d/19mt-vKtgLTvoqhR8TgbN9eSyGIkrrBjqjWfj8EDlZpU/edit?usp=drivesdk",
          "cachedResultName": "Conor's Cleaning - Knowledge Base Document"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "FVIK3OQQWPOoLCQq",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "3020c220-4e42-4c80-8bc8-7b93bc9a56e6",
      "name": "默认数据加载器1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1420,
        62.5
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "cc3f97fa-842d-45ae-ac51-6def07bfed1e",
      "name": "递归字符文本分割器1",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1508,
        260
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c448b82d-7145-4d46-a0e6-f2a01234331f",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        3280,
        1376.5
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5c1f5765-6d8e-429d-80d6-c9b3b15d4525",
      "name": "OpenAI 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1300,
        60
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0e500c88-38e1-4388-b0ef-116f95cf609c",
      "name": "OpenAI1 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3548,
        1576.5
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "SFP1ZJopx1UD494m",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3ecaba71-3c29-42dd-8440-cd5c574241b9",
      "name": "Postgres 聊天记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        3400,
        1376.5
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 3
      },
      "credentials": {
        "postgres": {
          "id": "1uobuv6Ly2ne6tEo",
          "name": "Postgres account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "086a122b-ffa3-43d5-9551-a8a9888c4bba",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -140
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 220,
        "content": "## ⚙️ 使用 Telegram 聊天机器人之前:"
      },
      "typeVersion": 1
    },
    {
      "id": "4d151254-2466-4c9b-9099-16f78cdf939f",
      "name": "Cohere 重排序器",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        3668,
        1576.5
      ],
      "parameters": {},
      "credentials": {
        "cohereApi": {
          "id": "I0Z04D8unX86r60W",
          "name": "CohereApi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "744219e9-66ef-45da-8d7c-a216862aca43",
      "name": "提取文本",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "74f774a8-e230-44fe-8d46-7a0ce7f34b42",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "76e0a4d6-8e34-4a87-9809-832c03d22097",
      "name": "提取文本和内容",
      "type": "n8n-nodes-base.set",
      "position": [
        2840,
        700
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5a6a5c34-c6bf-4d00-bb51-2ec5cd4af9e9",
              "name": "text",
              "type": "string",
              "value": "=Photo content: {{ $json.content }}\n\nPhoto caption: {{ $('Telegram Trigger').item.json.message.caption }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c366d6dc-bcf0-4bf8-952e-e4565e198c3a",
      "name": "提取错误消息",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        850
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cd3cb375-33a8-479e-b320-6d43e23c906e",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "89aa2812-0952-4ab5-8e3c-63e9ee7b9128",
      "name": "提取文本1",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1650
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "35b5e034-cf94-499c-967c-1aeb4edf1b58",
              "name": "text",
              "type": "string",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5313c3b4-ecc9-47d0-a15d-33b4f7bb1b5b",
      "name": "提取文本2",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1850
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d480f972-a046-4ff1-9d19-ac586c372cbd",
              "name": "text",
              "type": "string",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "676253d8-dc18-4915-9cff-8081bcb33f63",
      "name": "提取文本3",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        2050
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f7d3f22b-cca6-4d5d-9e70-b4075e542979",
              "name": "text",
              "type": "string",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c3807fa7-c537-4454-a2ac-baa8996d2808",
      "name": "提取文本4",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1050
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6bb76f62-7f3e-432d-9c96-4c1d1c3e15f1",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "428f828e-bef8-425a-90dc-b53ef786216e",
      "name": "提取文本5",
      "type": "n8n-nodes-base.set",
      "position": [
        3060,
        1450
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d26a3dd0-8bb2-4f25-9c7d-3542dc039861",
              "name": "text",
              "type": "string",
              "value": "={{ $json.data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9fe5eac7-98a4-40d4-8896-5af7ea86a278",
      "name": "添加到 Supabase 向量数据库",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        1316,
        -160
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "3RkTGbP6tJA6ruj6",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e080e0a0-053a-4648-87cf-ac322b423280",
      "name": "知识库 AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3312,
        1156.5
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": ""
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "d5cf1a5a-a84d-491e-922e-ce1628ab08db",
      "name": "Supabase 向量存储搜索",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        3520,
        1379
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        },
        "useReranker": true,
        "toolDescription": "Retrieve information about Conor’s Cleaning from the Supabase vector store."
      },
      "credentials": {
        "supabaseApi": {
          "id": "3RkTGbP6tJA6ruj6",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1.3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2fa6bed8-34b0-43c2-9ac0-6a77a9e60381",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Group Similar Documents",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        []
      ]
    },
    "Download PDF": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download XML": {
      "main": [
        [
          {
            "node": "Extract from XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mimeType": {
      "main": [
        [
          {
            "node": "Photo to text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download JSON": {
      "main": [
        [
          {
            "node": "Extract from JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Text": {
      "main": [
        [
          {
            "node": "Extract Text5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text1": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text2": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text3": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text4": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text5": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix mimeType1": {
      "main": [
        [
          {
            "node": "Photo to text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photo to text": {
      "main": [
        [
          {
            "node": "Extract Text & Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Translate to Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Fix mimeType",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Photo": {
      "main": [
        [
          {
            "node": "Fix mimeType1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File to Base64": {
      "main": [
        [
          {
            "node": "Convert to text (convertapi.com)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photo to text1": {
      "main": [
        [
          {
            "node": "Extract Text & Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Document Router": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Word Document",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Spreadsheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download JSON",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "Supabase Vector Store Search",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Extract Text4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from XML": {
      "main": [
        [
          {
            "node": "Extract Text3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Input Message Router",
            "type": "main",
            "index": 0
          },
          {
            "node": "Typing…",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from JSON": {
      "main": [
        [
          {
            "node": "Extract Text2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate to Text": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store Search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Add to Supabase Vector DB",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Download Spreadsheet": {
      "main": [
        [
          {
            "node": "Extract from Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Message Router": {
      "main": [
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Photo",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Supported Document File Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Extract Error Message": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Word Document": {
      "main": [
        [
          {
            "node": "File to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text & Content": {
      "main": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group Similar Documents": {
      "main": [
        [
          {
            "node": "Document Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base AI Agent": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Spreadsheet": {
      "main": [
        [
          {
            "node": "Extract Text1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store Search": {
      "ai_tool": [
        [
          {
            "node": "Knowledge Base AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Supported Document File Types": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to text (convertapi.com)": {
      "main": [
        [
          {
            "node": "Download Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Ezema Kingsley Chibuzo

Ezema Kingsley Chibuzo

@kingsley

Automation developer and AI workflow specialist with experience building end-to-end systems using n8n, OpenAI, Supabase, and other modern tools. I help businesses save time and scale operations through smart automation, AI agents, and no-code integrations.

外部链接
在 n8n.io 查看

分享此工作流