带有 PDF 文档和 Google Drive 备份的 Telegram RAG 聊天机器人
高级
这是一个Internal Wiki, AI RAG领域的自动化工作流,包含 24 个节点。主要使用 If, Code, Telegram, FormTrigger, GoogleDrive 等节点。 使用Telegram、OpenAI和Google Drive PDF备份构建检索式聊天机器人
前置要求
- •Telegram Bot Token
- •Google Drive API 凭证
- •OpenAI API Key
使用的节点 (24)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "bsT84L413PRtrNtZ",
"meta": {
"instanceId": "4a2e6764ba7a6bc9890d9225f4b21d570ce88fc9bd57549c89057fcee58fed0f",
"templateId": "5010",
"templateCredsSetupCompleted": true
},
"name": "带有 PDF 文档和 Google Drive 备份的 Telegram RAG 聊天机器人",
"tags": [
{
"id": "ow6eIe95VK6fRkyw",
"name": "Chatbot",
"createdAt": "2025-08-05T06:23:11.231Z",
"updatedAt": "2025-08-05T06:23:11.231Z"
},
{
"id": "JFZdpFVd2h3ZDZ7n",
"name": "RAG",
"createdAt": "2025-08-05T06:23:26.538Z",
"updatedAt": "2025-08-05T06:23:26.538Z"
},
{
"id": "84SlSTthTSHRbFGM",
"name": "Telegram",
"createdAt": "2025-08-05T06:23:21.764Z",
"updatedAt": "2025-08-05T06:23:21.764Z"
}
],
"nodes": [
{
"id": "26d63e24-2592-41f9-9b4b-edab81e99f21",
"name": "OpenAI 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1760,
720
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "PPSwAKeLQYgAPobT",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "3a69c8a7-bf95-4de2-84b0-ae2cc3d2e4e7",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1232,
1112
],
"parameters": {
"options": {},
"dataType": "binary"
},
"typeVersion": 1.1
},
{
"id": "0f4185ea-d7a9-44a9-a824-98f9dc2c2a5d",
"name": "插入数据到存储",
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"position": [
1136,
888
],
"parameters": {
"mode": "insert",
"memoryKey": {
"__rl": true,
"mode": "list",
"value": "vector_store_key",
"cachedResultName": "vector_store_key"
}
},
"typeVersion": 1.2
},
{
"id": "ce86b41b-7e1b-458f-ab13-d6b187854ae8",
"name": "查询数据工具",
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"position": [
1664,
512
],
"parameters": {
"mode": "retrieve-as-tool",
"toolName": "knowledge_base",
"memoryKey": {
"__rl": true,
"mode": "list",
"value": "vector_store_key"
},
"toolDescription": "Use this knowledge base to answer questions from the user"
},
"typeVersion": 1.2
},
{
"id": "d43cf585-4192-4f53-9532-4677923289ba",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1536,
512
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "PPSwAKeLQYgAPobT",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "8d4c68cf-64d1-4b3a-bb19-2f003303c1df",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1920,
688
],
"parameters": {
"color": 4,
"width": 320,
"height": 224,
"content": "### 嵌入"
},
"typeVersion": 1
},
{
"id": "d4227342-0a19-420e-b088-2e37186ad074",
"name": "Telegram触发器",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
912,
696
],
"webhookId": "aac0aa6a-c86e-4b4d-8f81-daacfd20f2c8",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "paNoPvnV5Wzt4Lhv",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "7470655a-650a-48ca-98e0-b248cf99d18e",
"name": "是文本消息吗?",
"type": "n8n-nodes-base.if",
"position": [
1224,
696
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2439fbb6-c093-4b33-aabd-db08ebfd53b2",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "fda67b3b-9844-40e4-aa53-252d2e36e667",
"name": "发送回复给用户",
"type": "n8n-nodes-base.telegram",
"position": [
2064,
496
],
"webhookId": "bead9b9b-6410-4fe7-a36c-05bd069e3a02",
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "paNoPvnV5Wzt4Lhv",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "62ae0117-0d2c-47dd-a772-7c4cd70885ec",
"name": "不支持的消息类型",
"type": "n8n-nodes-base.telegram",
"position": [
1688,
896
],
"webhookId": "724418e9-e7ef-4aa2-8722-028683cadb2f",
"parameters": {
"text": "Sorry, I can’t read files or images right now. Just send me your question about uploaded document, and I’ll help you answer it!",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "paNoPvnV5Wzt4Lhv",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "0039537b-558c-4fe8-9716-f8aa13676f4a",
"name": "Telegram 文档查询代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1552,
288
],
"parameters": {
"text": "={{ $json.message.text }}",
"options": {
"systemMessage": "The output should not exceed 3000 characters after entities parsing."
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "0608a9d7-db7b-4a18-b8fb-26b936da919a",
"name": "便签 6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1104,
512
],
"parameters": {
"width": 272,
"height": 144,
"content": "### 2. 是文本消息吗?"
},
"typeVersion": 1
},
{
"id": "40c8b84f-ed8a-4fdc-b04c-d778a2fdea0e",
"name": "便签说明5",
"type": "n8n-nodes-base.stickyNote",
"position": [
544,
688
],
"parameters": {
"width": 304,
"height": 128,
"content": "### 1. 📩 Telegram 触发器"
},
"typeVersion": 1
},
{
"id": "91077637-5e75-4bb2-8419-235420bc5a96",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
1224,
1288
],
"parameters": {
"jsCode": "const data = $input.item.json;\nconst binaryData = $input.item.binary;\n\nlet output = [];\n\nObject.keys(binaryData)\n .filter(label => label.startsWith(\"CV_\"))\n .forEach(label => {\n output.push({\n json: data,\n binary: { data: binaryData[label] }\n });\n });\n\nreturn output;"
},
"typeVersion": 2
},
{
"id": "83ed351e-90e8-458f-a01b-73001ef1800f",
"name": "在此处上传您的 PDF 文档",
"type": "n8n-nodes-base.formTrigger",
"position": [
912,
1140
],
"webhookId": "82848bc4-5ea2-4e5a-8bb6-3c09b94a8c5d",
"parameters": {
"options": {},
"formTitle": "Upload your data to test RAG",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "Upload your file(s)",
"requiredField": true,
"acceptFileTypes": ".pdf"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "79a7f8b5-7af2-479c-883c-a4e02ce4bee8",
"name": "备份文档到 Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
1688,
1288
],
"parameters": {
"name": "=document-{{ $now.toFormat(\"yyyyLLdd-HHmmss\") }}-{{$binary.data.fileName}}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1ObNNVJFR2vcKqP8p-ZnX_eaZy4gBHgha",
"cachedResultUrl": "https://drive.google.com/drive/folders/1ObNNVJFR2vcKqP8p-ZnX_eaZy4gBHgha",
"cachedResultName": "SmartIT"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "fC471es5gk5Mm900",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "c8f73ac1-eb95-4fa0-a1d8-8b6f5befe885",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-752,
-96
],
"parameters": {
"color": 7,
"width": 1264,
"height": 1856,
"content": "# 📚 带有 PDF 文档和 Google Drive 备份的 Telegram RAG 聊天机器人"
},
"typeVersion": 1
},
{
"id": "8ecf58dd-5beb-4f78-bd09-1238f25c623a",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
704,
1360
],
"parameters": {
"width": 464,
"height": 80,
"content": "### 1. 在此处上传您的 PDF 文档"
},
"typeVersion": 1
},
{
"id": "2aefbbd3-1234-4843-bf34-430b229faa1f",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1872,
1296
],
"parameters": {
"width": 432,
"height": 80,
"content": "### 2.1 备份文档到 Google Drive"
},
"typeVersion": 1
},
{
"id": "88a087f2-8656-4e82-b384-efdaf51ec021",
"name": "便签说明4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1424,
176
],
"parameters": {
"width": 560,
"height": 96,
"content": "### 3. Telegram 文档查询代理(带 RAG 的 GPT)"
},
"typeVersion": 1
},
{
"id": "38627375-43c0-47ad-87ab-a3ef94093c28",
"name": "便签 7",
"type": "n8n-nodes-base.stickyNote",
"position": [
1360,
1120
],
"parameters": {
"color": 4,
"width": 496,
"height": 96,
"content": "### 默认数据加载器"
},
"typeVersion": 1
},
{
"id": "8b2e116c-003f-4eb7-9cf1-30ac4cbd87d3",
"name": "便签 9",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
896
],
"parameters": {
"width": 352,
"height": 112,
"content": "### 2.2 插入数据到存储(嵌入)"
},
"typeVersion": 1
},
{
"id": "2abc9178-add2-4d8e-b395-cc9713ed4a2e",
"name": "便签10",
"type": "n8n-nodes-base.stickyNote",
"position": [
2432,
480
],
"parameters": {
"width": 540,
"height": 580,
"content": ""
},
"typeVersion": 1
},
{
"id": "1de83861-0a7d-4e0c-9ceb-beacbe84749b",
"name": "## 为什么选择 4o 模型?👆",
"type": "n8n-nodes-base.stickyNote",
"position": [
2432,
1088
],
"parameters": {
"width": 544,
"height": 80,
"content": "示例文档:https://ptgmedia.pearsoncmg.com/images/9780138203283/samplepages/9780138203283_Sample.pdf"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {},
"versionId": "50ae16d0-7565-4f29-8f21-d769face925a",
"connections": {
"Code": {
"main": [
[
{
"node": "Backup document(s) to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Query Data Tool": {
"ai_tool": [
[
{
"node": "Telegram document query agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Is text message?": {
"main": [
[
{
"node": "Telegram document query agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Un-supported message type",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Is text message?",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Insert Data to Store",
"type": "ai_embedding",
"index": 0
},
{
"node": "Query Data Tool",
"type": "ai_embedding",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Telegram document query agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Insert Data to Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Insert Data to Store": {
"main": [
[]
]
},
"Send respond to user": {
"main": [
[]
]
},
"Telegram document query agent": {
"main": [
[
{
"node": "Send respond to user",
"type": "main",
"index": 0
}
]
]
},
"Upload your PDF document here": {
"main": [
[
{
"node": "Insert Data to Store",
"type": "main",
"index": 0
},
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内部知识库, AI RAG 检索增强
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
行为准则问答 Slack 聊天机器人(RAG 驱动)
使用 GPT-4 和 RAG 技术在 Slack 中回答行为准则问题
If
Code
Slack
+10
24 节点Trung Tran
AI RAG 检索增强
用于更智能BRD(业务需求文档)编写的多Agent RAG系统
使用多Agent GPT和Google Workspace生成业务需求文档
Set
Code
Merge
+14
37 节点Trung Tran
AI RAG 检索增强
使用Rag自动重新发布工作
基于 RAG、Jina AI 和 OpenAI 到 WordPress 的自动化职位提取与发布
If
Set
Code
+18
56 节点Khairul Muhtadin
人力资源
Telegram AI支持聊天机器人(多模态输入)
使用GPT-4和Supabase RAG创建多模态Telegram支持机器人
If
Set
Code
+17
51 节点Ezema Kingsley Chibuzo
客服机器人
AI知识库助手与OpenAI、Supabase及Google Drive文档同步
AI知识库助手与OpenAI、Supabase及Google Drive文档同步
Set
Limit
Switch
+16
49 节点Abdul Mir
内部知识库
文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
If
Set
Code
+16
40 节点DIGITAL BIZ TECH
内部知识库
工作流信息
难度等级
高级
节点数量24
分类2
节点类型12
作者
Trung Tran
@trungtranEmpowering small and medium businesses with smart automation and practical AI, no big tech team required. Reach out: lets@automatewith.me
外部链接
在 n8n.io 查看 →
分享此工作流