智能知识助手
这是一个Support, AI领域的自动化工作流,包含 26 个节点。主要使用 Set, Code, Telegram, GoogleDocs, ManualTrigger 等节点,结合人工智能技术实现智能自动化。 在Telegram上使用GPT-4o-mini、RAG和RLHF构建智能知识助手,集成MongoDB
- •Telegram Bot Token
- •OpenAI API Key
- •MongoDB 连接字符串
使用的节点 (26)
{
"meta": {
"instanceId": "074f90e2bb5206c5f405a8aac6551497c72005283a5405fb08207b1b3a78c2b8",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "e39a0b25-53ce-4ac0-9c93-7750b8e6105b",
"name": "知识库代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
220,
0
],
"parameters": {
"text": "={{ $json.message.text }}",
"options": {
"systemMessage": "You are the AI assistant for a company specializing in advanced technology solutions. Your task is to help internal users by consulting the official product documentation for the company’s platforms.\n\nAvailable References:\n\nproductDocs: Step-by-step guides, technical configurations, and official manuals from the developer documentation.\n\nfeedbackPositive: Previous responses rated positively by users, useful as examples for generating high-quality answers.\n\nfeedbackNegative: Previous responses rated negatively by users. Use this tool to avoid making similar mistakes in your replies.\n\nCurrently, there are no use cases or update history documented in the available materials.\n\nBehavior Rules\n\nSearch & Response:\n\nAlways consult the official documentation first using the productDocs tool.\n\nAlso search feedbackPositive for highly rated previous responses to similar questions.\n\nCheck feedbackNegative to see if similar answers were poorly rated, and avoid repeating those mistakes.\n\nIf multiple tools return relevant results, combine the information to provide the best answer. If only one tool returns relevant content, use that as your source.\n\nRespond directly and clearly, explaining exactly how to perform the requested task.\n\nDo not filter by category unless the user explicitly asks.\n\nLanguage (Strict Per-Message Rule):\n\nDetect the language of each incoming message individually.\n\nRespond in the same language as the most recent message.\n\nDo not use the language of previous messages or conversation history to decide the language.\n\nLinks (Not Allowed):\n\nNever provide links, even if the user requests them.\n\nIf a user asks for a link, respond with:\n“I cannot provide links. If you need specific information, let me know and I will help with the details.”\n\nResponse Style:\n\nUse a professional, direct, and human tone.\n\nKeep responses between 2 and 4 lines unless the user asks for more detail.\n\nDo not make up information that isn’t in MongoDB.\n\nIf your answer contains numbered steps or lists, always number them sequentially (1, 2, 3...) without skipping or repeating numbers, even if the original content uses a different numbering style."
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "775b7991-88f3-4959-a068-3fb2b667567e",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
200,
180
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "4c2e0ea6-f5d0-4d5b-a065-606b2dc2cff5",
"name": "OpenAI嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
440,
460
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "2f813af6-3432-4201-93d0-ff503013642e",
"name": "文档分段加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
580,
-340
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "doc_id",
"value": "={{ $json.documentId }}"
}
]
}
},
"jsonData": "={{ $json.content }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "c6386d7b-f3cb-4884-9477-a69e9743e6c6",
"name": "文档分块器",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
560,
-220
],
"parameters": {
"options": {
"splitCode": "markdown"
},
"chunkSize": 3000,
"chunkOverlap": 200
},
"typeVersion": 1
},
{
"id": "4ff1a843-5e1c-4a23-bdf3-2fdc91ba7032",
"name": "OpenAI 嵌入生成器",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
440,
-340
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "64624ed6-cbb2-43c1-b348-df92f26d8efe",
"name": "Google Docs 导入器",
"type": "n8n-nodes-base.googleDocs",
"position": [
220,
-520
],
"parameters": {
"operation": "get",
"documentURL": "https://docs.google.com/document/d/1gvgp71e9edob8WLqFIYCdzC7kUq3pLO37VKb-a-vVW4/edit?tab=t.0"
},
"credentials": {
"googleDocsOAuth2Api": {
"id": "FNXMwqMf7vl1WUFj",
"name": "Google Docs account"
}
},
"typeVersion": 2
},
{
"id": "09c262ab-ba89-429c-b8a8-41c3ae79d97c",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
-500
],
"parameters": {
"color": 5,
"content": "手动运行此工作流,将 Google Docs 产品文档导入 MongoDB 并建立向量嵌入索引以实现快速搜索。"
},
"typeVersion": 1
},
{
"id": "f309ff4a-194f-413a-b8f5-d8210cb5e0c6",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-420,
40
],
"parameters": {
"color": 4,
"height": 180,
"content": "此工作流使用检索增强生成(RAG)来回答用户问题,通过搜索 MongoDB 向量存储并生成结合 Telegram 基于 RLHF 反馈增强的 AI 响应。"
},
"typeVersion": 1
},
{
"id": "caf481b3-7a19-40df-b5fb-52e74a8edd73",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1800,
-480
],
"parameters": {
"width": 520,
"height": 1040,
"content": "文档搜索索引"
},
"typeVersion": 1
},
{
"id": "8a3abf9e-6f3f-47cf-b9ec-bb9da9835e5c",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
0,
-520
],
"parameters": {},
"typeVersion": 1
},
{
"id": "4235ba8c-d671-40b8-b3a4-d7cccac36d54",
"name": "MongoDB 聊天记忆",
"type": "@n8n/n8n-nodes-langchain.memoryMongoDbChat",
"position": [
320,
180
],
"parameters": {
"sessionKey": "={{ $('Receive Message on Telegram').item.json.message.chat.id }}",
"sessionIdType": "customKey",
"collectionName": "n8n-template-chat-history"
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1
},
{
"id": "000e272a-3f19-4c17-86b5-07505eba2c3b",
"name": "嵌入 OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
160,
440
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "dca02c04-2921-4982-83a3-6b2f6fb32663",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1400,
180
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "prompt",
"value": "={{ $json.prompt }}"
},
{
"name": "response",
"value": "={{ $json.response }}"
},
{
"name": "feedback",
"value": "={{ $json.feedback }}"
}
]
}
},
"jsonData": "={{ $json.text }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "757073e3-f8b5-42b5-ab02-d310d5f6e8a4",
"name": "递归字符文本分割器",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
1380,
300
],
"parameters": {
"options": {},
"chunkSize": 4000
},
"typeVersion": 1
},
{
"id": "588ef94b-9723-440a-ac13-d97d744ae26d",
"name": "OpenAI3 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
320,
720
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "355654d8-95e2-4337-9b1f-af2a08573f08",
"name": "搜索积极互动",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
160,
320
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {
"metadata": {
"metadataValues": [
{
"name": "feedback",
"value": "positive"
}
]
}
},
"toolName": "feedbackPositive",
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "n8n-template-feedback",
"cachedResultName": "n8n-template-feedback"
},
"toolDescription": "Retrieve previous examples of similar questions that were rated positively by users. Use this tool before responding to improve your answer based on those approved examples.",
"vectorIndexName": "template-feedback-search"
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1.1
},
{
"id": "84a95dfb-6cc4-4a18-be40-6fa201073750",
"name": "搜索文档",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
440,
320
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {},
"toolName": "productDocs",
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "n8n-template",
"cachedResultName": "n8n-template"
},
"toolDescription": "retreive documentation",
"vectorIndexName": "data_index"
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1.1
},
{
"id": "f2001c81-081b-4417-8349-3db459c0f191",
"name": "搜索负面互动",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
240,
580
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {
"metadata": {
"metadataValues": [
{
"name": "feedback",
"value": "negative"
}
]
}
},
"toolName": "feedbackNegative",
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "n8n-template-feedback",
"cachedResultName": "n8n-template-feedback"
},
"toolDescription": "Retrieve previous examples of similar questions that were rated negatively by users. Use this tool before responding to avoid generating answers similar to those that did not work well in the past.",
"vectorIndexName": "template-feedback-search"
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1.1
},
{
"id": "1a0de194-3508-4d21-b1a2-35c3b4a998c1",
"name": "在 Telegram 上接收消息",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
0,
0
],
"webhookId": "fff1b90c-59ce-406b-a7f0-08953c90c0ce",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "wb9guorEXe6W5V8C",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "92458560-feb5-40df-b52a-ec1c5156829d",
"name": "在 Telegram 上发送消息,等待反馈",
"type": "n8n-nodes-base.telegram",
"position": [
600,
0
],
"webhookId": "ed8fc221-70ad-47df-b70e-6667c580553b",
"parameters": {
"chatId": "={{ $('Receive Message on Telegram').item.json.message.chat.id }}",
"message": "={{ $json.output }}",
"options": {
"appendAttribution": false
},
"operation": "sendAndWait",
"approvalOptions": {
"values": {
"approvalType": "double"
}
}
},
"credentials": {
"telegramApi": {
"id": "wb9guorEXe6W5V8C",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "ef40200d-5f19-4199-8ae3-9f2e0f52ac1b",
"name": "映射反馈数据",
"type": "n8n-nodes-base.code",
"position": [
820,
0
],
"parameters": {
"jsCode": "let response;\n\nif ($input.first().json.data.approved) {\n response = \"positive\"\n} \nelse {\n response = \"negative\"\n}\n\nreturn {\n feedback: response\n}\n"
},
"typeVersion": 2
},
{
"id": "d688073c-9a97-4b39-9640-c368cccf3491",
"name": "为集合存储设置反馈字段",
"type": "n8n-nodes-base.set",
"position": [
1040,
0
],
"parameters": {
"values": {
"string": [
{
"name": "prompt",
"value": "={{ $('Receive Message on Telegram').item.json.message.text }}"
},
{
"name": "response",
"value": "={{ $('Knowledge Base Agent').item.json.output }}"
},
{
"name": "text",
"value": "=Prompt: {{ $('Receive Message on Telegram').item.json.message.text }}. Completion: {{ $('Knowledge Base Agent').item.json.output }}"
},
{
"name": "feedback",
"value": "={{ $json.feedback }}"
}
]
},
"options": {},
"keepOnlySet": true
},
"typeVersion": 1
},
{
"id": "9907480f-3e5d-4240-adbb-790be2d68496",
"name": "提交嵌入式聊天反馈",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
1260,
0
],
"parameters": {
"mode": "insert",
"options": {},
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "n8n-template-feedback",
"cachedResultName": "n8n-template-feedback"
},
"vectorIndexName": "template-feedback-search",
"embeddingBatchSize": 1
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1.1
},
{
"id": "1a470ad3-845a-4890-b103-65a21b1940de",
"name": "OpenAI 嵌入生成器1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1260,
180
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cJRah9hGPQ7eX4jd",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "fdc22256-f014-4ed0-8781-1abb20134b1a",
"name": "MongoDB 文档插入器",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
440,
-520
],
"parameters": {
"mode": "insert",
"options": {},
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "n8n-template",
"cachedResultName": "n8n-template"
},
"vectorIndexName": "data_index"
},
"credentials": {
"mongoDb": {
"id": "7riubYENUDZsmjyK",
"name": "MongoDB account 2"
}
},
"typeVersion": 1.1
}
],
"pinData": {},
"connections": {
"Document Chunker": {
"ai_textSplitter": [
[
{
"node": "Document Section Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Search Documentation",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Map feedback data": {
"main": [
[
{
"node": "Set feedback fields for collection storage",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Search Positive Interactions",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI3": {
"ai_embedding": [
[
{
"node": "Search Negative Interactions",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Submit embedded chat feedback",
"type": "ai_document",
"index": 0
}
]
]
},
"MongoDB Chat Memory": {
"ai_memory": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Google Docs Importer": {
"main": [
[
{
"node": "MongoDB Documentation Inserter",
"type": "main",
"index": 0
}
]
]
},
"Knowledge Base Agent": {
"main": [
[
{
"node": "Send Message on Telegram, Wait for Feedback",
"type": "main",
"index": 0
}
]
]
},
"Search Documentation": {
"ai_tool": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Document Section Loader": {
"ai_document": [
[
{
"node": "MongoDB Documentation Inserter",
"type": "ai_document",
"index": 0
}
]
]
},
"OpenAI Embeddings Generator": {
"ai_embedding": [
[
{
"node": "MongoDB Documentation Inserter",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Receive Message on Telegram": {
"main": [
[
{
"node": "Knowledge Base Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Embeddings Generator1": {
"ai_embedding": [
[
{
"node": "Submit embedded chat feedback",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Search Negative Interactions": {
"ai_tool": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Search Positive Interactions": {
"ai_tool": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"MongoDB Documentation Inserter": {
"main": [
[]
]
},
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Google Docs Importer",
"type": "main",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Set feedback fields for collection storage": {
"main": [
[
{
"node": "Submit embedded chat feedback",
"type": "main",
"index": 0
}
]
]
},
"Send Message on Telegram, Wait for Feedback": {
"main": [
[
{
"node": "Map feedback data",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客户支持, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
NovaNode
@thomasgptNovaNode is a software factory building scalable AI for modern businesses. We specialize in omni-channel AI agents that automate customer support, sales, and operations across voice, WhatsApp, email, and chat. We serve both enterprise clients and SMEs, balancing deep integrations with speed and cost-efficiency. By combining automation with adaptability, we help companies scale faster and operate smarter. NovaNode is where AI meets execution.
分享此工作流