基于AI的Nextcloud文档聊天系统,使用LangChain和OpenAI
高级
这是一个AI, IT Ops领域的自动化工作流,包含 21 个节点。主要使用 If, Set, Code, Switch, Aggregate 等节点,结合人工智能技术实现智能自动化。 基于AI的Nextcloud文档聊天系统,使用LangChain和OpenAI
前置要求
- •OpenAI API Key
使用的节点 (21)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "634e789e9cac462123b2b4acaedfe20e105965d27f018a60d1d4305ae72b1acb"
},
"nodes": [
{
"id": "9745c907-14fe-49b8-9acf-b4e847bf2ebc",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-1060,
-200
],
"webhookId": "42ca02f5-5d57-41aa-a8c7-34db652e2493",
"parameters": {
"public": true,
"options": {},
"initialMessages": "Hi there! 👋\nMy name is Johan. How can I assist you today?"
},
"typeVersion": 1.1
},
{
"id": "aa540b75-cb88-4f09-b76a-c1a66b2eb34b",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1000,
40
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "qwen3-235b-a22b",
"cachedResultName": "qwen3-235b-a22b"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "e3etpZ3VT4nd9brg",
"name": "gwdg api"
}
},
"typeVersion": 1.2
},
{
"id": "fcb5b3c9-c0d4-41b1-8f76-58c2bb1bf822",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-840,
40
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "da680124-9c4e-4bb7-9d70-8ae0d5515bb0",
"name": "AI Nextcloud",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-860,
-200
],
"parameters": {
"options": {}
},
"typeVersion": 1.9
},
{
"id": "cce0ea8a-5bd1-48ad-9e2c-bca053755278",
"name": "当被另一个工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-1620,
580
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "path"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "d382c346-4f35-4772-a3e3-2104be66ffce",
"name": "切换",
"type": "n8n-nodes-base.switch",
"position": [
-720,
500
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "pdf",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "902f5ebf-b91a-48d1-a1bf-9a46c98a0853",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "application/pdf"
}
]
},
"renameOutput": true
},
{
"outputKey": "md",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8c48e515-832a-421c-8cde-7c1123c14467",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "text/markdown"
}
]
},
"renameOutput": true
},
{
"outputKey": "docx",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "044f36c5-5787-4308-9b49-8b28d0288649",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "14addc84-0661-4913-bf6b-9870cce876bf",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
-60,
500
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "e7a14c39-5853-4e2f-8549-47917eedd3ac",
"name": "输出",
"type": "n8n-nodes-base.set",
"position": [
120,
500
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "0f77cdc0-3115-4abd-91aa-069a36b1a7ac",
"name": "output",
"type": "string",
"value": "={{ $json.data }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "dc6ee0ee-b2e8-433d-8acb-b182dc6e8529",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1700,
260
],
"parameters": {
"color": 6,
"width": 2080,
"height": 700,
"content": "# 子工作流"
},
"typeVersion": 1
},
{
"id": "858059e4-6a66-4442-8a04-d9cd4fd6dcc0",
"name": "如果可读",
"type": "n8n-nodes-base.if",
"position": [
-1120,
580
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "dcc91aaa-d9bb-4c11-88b7-c569f811ec1d",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "pdf"
},
{
"id": "b7695016-8a8d-460e-977e-f415443df1f2",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "markdown"
},
{
"id": "ca8021f0-a853-4a09-aee9-96494a66d131",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.contentType }}",
"rightValue": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "e3341daa-f89d-4666-848a-1dbcfb7a9f74",
"name": "获取文件",
"type": "n8n-nodes-base.nextCloud",
"position": [
-1300,
580
],
"parameters": {
"path": "={{ $json.path }}",
"resource": "folder",
"operation": "list"
},
"credentials": {
"nextCloudApi": {
"id": "3nENap8sZI7MN816",
"name": "NextCloud account"
}
},
"typeVersion": 1
},
{
"id": "23d1168d-c0f1-412c-bfe2-fc229cd0567a",
"name": "下载文件",
"type": "n8n-nodes-base.nextCloud",
"position": [
-900,
500
],
"parameters": {
"path": "={{ $json.path.urlDecode() }}",
"operation": "download"
},
"credentials": {
"nextCloudApi": {
"id": "3nENap8sZI7MN816",
"name": "NextCloud account"
}
},
"typeVersion": 1
},
{
"id": "9aaeb43a-6156-4c72-a090-9eb07fb2a85c",
"name": "添加路径1",
"type": "n8n-nodes-base.code",
"position": [
-320,
300
],
"parameters": {
"jsCode": "for (const item of $input.all()) {\n item.json.path = $('Switch').first().json.path;\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "fe21734c-e0e5-43f3-8bb9-4fd976ab61a9",
"name": "添加路径2",
"type": "n8n-nodes-base.code",
"position": [
-320,
500
],
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.path = $('Switch').first().json.path;\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "46bb7f6b-7a0d-4761-b50b-50ed8a0fd01a",
"name": "添加路径3",
"type": "n8n-nodes-base.code",
"position": [
-320,
720
],
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.path = $('Switch').first().json.path;\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "6124f284-2846-4c88-b075-2a2fec028664",
"name": "测试数据",
"type": "n8n-nodes-base.code",
"position": [
-1460,
580
],
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.path = item.json.path || '/test/folder';\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "7b11ef64-3887-4baa-a8ca-3c76c8f4eb02",
"name": "Nextcloud工具",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
-700,
40
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "fni6RBWYOcTGA0tT",
"cachedResultName": "nextcloud-folder"
},
"description": "调用此工具从文件夹(在Nextcloud中)读取文件。将文件夹路径作为参数传递。",
"workflowInputs": {
"value": {
"path": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('path', ``, 'string') }}"
},
"schema": [
{
"id": "path",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "path",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"path"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "c78d765f-b6fe-40bb-9245-3ce50cb009b4",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1700,
-260
],
"parameters": {
"width": 1260,
"height": 460,
"content": "# 主工作流"
},
"typeVersion": 1
},
{
"id": "147fe75b-022f-4fb0-8259-bc91286f54ca",
"name": "PDF",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-500,
300
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "1bd71897-738a-46a2-b7e3-700e4ad9db8f",
"name": "Markdown",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-500,
500
],
"parameters": {
"options": {},
"operation": "text",
"destinationKey": "text"
},
"typeVersion": 1
},
{
"id": "9ed19c46-55aa-4109-85c7-a8b9cf068568",
"name": "DOCX",
"type": "n8n-nodes-word2text.word2text",
"position": [
-500,
740
],
"parameters": {},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"PDF": {
"main": [
[
{
"node": "add path 1",
"type": "main",
"index": 0
}
]
]
},
"DOCX": {
"main": [
[
{
"node": "add path 3",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "PDF",
"type": "main",
"index": 0
}
],
[
{
"node": "Markdown",
"type": "main",
"index": 0
}
],
[
{
"node": "DOCX",
"type": "main",
"index": 0
}
]
]
},
"Markdown": {
"main": [
[
{
"node": "add path 2",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "output",
"type": "main",
"index": 0
}
]
]
},
"Get Files": {
"main": [
[
{
"node": "If readable",
"type": "main",
"index": 0
}
]
]
},
"test data": {
"main": [
[
{
"node": "Get Files",
"type": "main",
"index": 0
}
]
]
},
"add path 1": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"add path 2": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"add path 3": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"If readable": {
"main": [
[
{
"node": "Download File",
"type": "main",
"index": 0
}
]
]
},
"Download File": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Nextcloud",
"type": "ai_memory",
"index": 0
}
]
]
},
"Nextcloud Tool": {
"ai_tool": [
[
{
"node": "AI Nextcloud",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Nextcloud",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Nextcloud",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "test data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
构建自定义n8n工作流MCP服务器
构建自定义n8n工作流MCP服务器
If
N8n
Set
+15
46 节点Jimleuk
其他
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG 检索增强
AI智能助手与Airtable对话及数据分析
AI智能助手与Airtable对话及数据分析
If
Set
Merge
+12
41 节点Mark Shcherbakov
工程
基于AI的MIS代理
基于AI的管理信息系统代理
If
Set
Code
+29
129 节点Kumar Shivam
客户支持
创建品牌化AI驱动的网站聊天机器人
创建品牌化AI驱动的网站聊天机器人
If
Set
Code
+12
24 节点Wayne Simpson
产品
AI智能助手:与Supabase存储和Google Drive文件对话
AI智能助手:与Supabase存储和Google Drive文件对话
If
Set
Wait
+20
62 节点Mark Shcherbakov
工程