基于文档问答的 Telegram AI 聊天机器人(OpenAI 与 PGVector RAG)
高级
这是一个Support, AI领域的自动化工作流,包含 29 个节点。主要使用 Set, Code, Postgres, SplitOut, GoogleDrive 等节点,结合人工智能技术实现智能自动化。 使用 OpenAI 和 PGVector RAG 实现文档问答的 Telegram AI 聊天机器人
前置要求
- •PostgreSQL 数据库连接信息
- •Google Drive API 凭证
- •OpenAI API Key
使用的节点 (29)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "1dbc26c48fe55fbd6f6084822260e5ffcc6df7c619b3d6ceeb699da53e67c82c",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "ab11aca6-163b-4995-a2c1-89146aca4d13",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
3100,
460
],
"parameters": {},
"typeVersion": 1
},
{
"id": "5397732c-4b72-4d67-bc83-d131d6fe6a6a",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
2160,
1000
],
"parameters": {},
"typeVersion": 1
},
{
"id": "15b136fe-d236-4016-82e5-2cd45188cfc3",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
2040,
1000
],
"parameters": {},
"typeVersion": 1
},
{
"id": "67f63eac-3d80-4453-8378-31c245e40158",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-380,
160
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "96577cfc-9c82-48da-a8bb-6b3c1bafc232",
"name": "下载文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
560,
660
],
"parameters": {},
"executeOnce": true,
"typeVersion": 3
},
{
"id": "b3805cd6-52e7-462c-9239-a573c8484bf9",
"name": "文件已创建",
"type": "n8n-nodes-base.googleDriveTrigger",
"position": [
-320,
660
],
"parameters": {},
"typeVersion": 1
},
{
"id": "b6a8743b-1e69-41a4-b410-410943583512",
"name": "文件已更新",
"type": "n8n-nodes-base.googleDriveTrigger",
"position": [
-320,
840
],
"parameters": {},
"typeVersion": 1
},
{
"id": "36af5de3-7bfc-473a-a14d-f671a38c8212",
"name": "提取文档文本",
"type": "n8n-nodes-base.extractFromFile",
"position": [
780,
660
],
"parameters": {},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "cb6f5d94-033e-4dd0-a09c-4d92fe07ecb6",
"name": "设置文件 ID",
"type": "n8n-nodes-base.set",
"position": [
120,
660
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "23f43960-5c13-43be-9450-af9c82c5f4d2",
"name": "RAG AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
3140,
240
],
"parameters": {},
"typeVersion": 1.6
},
{
"id": "a2a4faee-8109-4f55-b30b-6e6294845088",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-100,
660
],
"parameters": {},
"typeVersion": 3
},
{
"id": "ceef932c-f667-4ed8-8014-b650a3546fb0",
"name": "递归字符文本分割器",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
2160,
1160
],
"parameters": {},
"typeVersion": 1
},
{
"id": "f59122eb-4e34-4765-90be-86f3507e9a65",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"disabled": true,
"position": [
2600,
240
],
"webhookId": "2e7c037a-cf2e-40c5-9bed-e0944cc03cfa",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "61852ba7-292a-4b8c-b774-6df4d2d4d7c5",
"name": "从文档创建块",
"type": "n8n-nodes-base.code",
"position": [
1000,
660
],
"parameters": {},
"typeVersion": 2
},
{
"id": "5231cf12-4061-4793-b918-f02bd021c333",
"name": "块到列表",
"type": "n8n-nodes-base.splitOut",
"position": [
1220,
660
],
"parameters": {},
"typeVersion": 1
},
{
"id": "a37aa716-8d50-4ecd-a8de-44ca198386c3",
"name": "生成上下文文本",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1440,
660
],
"parameters": {},
"typeVersion": 1.4
},
{
"id": "b053ea08-d6a9-4718-a86b-3d44aa8e19b9",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1460,
820
],
"parameters": {},
"typeVersion": 1.2
},
{
"id": "6cf0dbc3-835f-4c99-b3b0-c5db7c379394",
"name": "获取值",
"type": "n8n-nodes-base.set",
"position": [
1820,
660
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "05270c8c-a1de-4be9-80ff-84fbf84e8578",
"name": "Postgres PGVector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
"position": [
2060,
780
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "71b60f18-4e1c-45bd-840c-5f3f113675f7",
"name": "删除旧文档记录",
"type": "n8n-nodes-base.postgres",
"position": [
340,
660
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "3ff8d9fb-f420-4939-b925-03e8fa7506d7",
"name": "当被其他工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
2600,
400
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "b1d273cb-1730-40eb-93e7-95305e6ce091",
"name": "文档 RAG 工具",
"type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
"position": [
3520,
380
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "9609e4cc-6d65-4364-97f8-0e79c0b36a2d",
"name": "嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
3520,
520
],
"parameters": {},
"typeVersion": 1.2
},
{
"id": "df6ee67c-f983-4428-b0b8-cd0522d45298",
"name": "聊天记忆",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"position": [
3260,
460
],
"parameters": {},
"notesInFlow": false,
"typeVersion": 1
},
{
"id": "6e33fb90-9dd1-4ef8-a5e6-9081aca23ec5",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
2540,
160
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "0b6cd331-8202-413f-a721-43290d9e51d0",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-380,
-1180
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "e2d556be-1c64-4834-b6f6-ed469753ce09",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2540,
-740
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "e54d26de-fb3e-491d-a23d-3986dfd36a2e",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-380,
1380
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "5d1a8354-a538-44d8-8d30-fd74084e2ea3",
"name": "测试数据",
"type": "n8n-nodes-base.set",
"notes": "You can use it for test workflow without trigger",
"disabled": true,
"position": [
2820,
400
],
"parameters": {},
"notesInFlow": true,
"typeVersion": 3.4
}
],
"pinData": {},
"connections": {
"TestData": {
"main": [
[
{
"node": "RAG AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Embeddings": {
"ai_embedding": [
[
{
"node": "Docs RAG Tool",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Get Values": {
"main": [
[
{
"node": "Postgres PGVector Store",
"type": "main",
"index": 0
}
]
]
},
"Chat Memory": {
"ai_memory": [
[
{
"node": "RAG AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Set File ID": {
"main": [
[
{
"node": "Delete Old Doc Records",
"type": "main",
"index": 0
}
]
]
},
"File Created": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"File Updated": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Docs RAG Tool": {
"ai_tool": [
[
{
"node": "RAG AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Download File": {
"main": [
[
{
"node": "Extract Document Text",
"type": "main",
"index": 0
}
]
]
},
"Chunks To List": {
"main": [
[
{
"node": "Generate Contextual Text",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Set File ID",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "RAG AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Postgres PGVector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"OpenAI Chat Model3": {
"ai_languageModel": [
[
{
"node": "Generate Contextual Text",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Postgres PGVector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Extract Document Text": {
"main": [
[
{
"node": "Create Chunks From Doc",
"type": "main",
"index": 0
}
]
]
},
"Create Chunks From Doc": {
"main": [
[
{
"node": "Chunks To List",
"type": "main",
"index": 0
}
]
]
},
"Delete Old Doc Records": {
"main": [
[
{
"node": "Download File",
"type": "main",
"index": 0
}
]
]
},
"Postgres PGVector Store": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Generate Contextual Text": {
"main": [
[
{
"node": "Get Values",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "TestData",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客户支持, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于AI的MIS代理
基于AI的管理信息系统代理
If
Set
Code
+29
129 节点Kumar Shivam
客户支持
宠物店 4
🐶 宠物店预约 AI 代理
If
Set
Code
+41
187 节点Bruno Dias
人工智能
[模板] AI宠物店 v8
🐶 AI宠物店助手 - 集成GPT-4o、Google日历和WhatsApp/Instagram/Facebook
If
N8n
Set
+38
244 节点Amanda Benks
销售
AI 代理餐厅 [模板]
🤖 WhatsApp、Instagram 和 Messenger 的 AI 餐厅助手
If
N8n
Set
+37
239 节点Amanda Benks
其他
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG 检索增强
工作流信息
难度等级
高级
节点数量29
分类2
节点类型19
作者
Victor Gold
@victorluckyAutomation & AI expert with over 7 years of experience in the digital & tech industry. Founder digital design, web & mobile development studio INSAIM.DESIGN. Focusing on startups & tech companies and helping to streamline their processes with AI and automation.
外部链接
在 n8n.io 查看 →
分享此工作流