使用GPT-4和可复用思考工具创建多步推理AI代理
中级
这是一个Engineering, AI Chatbot领域的自动化工作流,包含 11 个节点。主要使用 Agent, ChatTrigger, LmChatOpenAi, ToolWorkflow, ExecuteWorkflowTrigger 等节点。 使用GPT-4和可复用思考工具创建多步推理AI代理
前置要求
- •OpenAI API Key
使用的节点 (11)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"nodes": [
{
"id": "97a1c69c-d9b4-44a4-a533-25c1af48b38f",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-32,
-96
],
"webhookId": "35e86578-a7fb-4973-9783-9963602c9bb6",
"parameters": {
"options": {}
},
"typeVersion": 1.3
},
{
"id": "3a6435c3-636b-4e88-b4be-3fdc7af4f587",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
208,
-128
],
"parameters": {
"options": {
"systemMessage": "You are a very smart assistant.\n\nYou always start by calling the tool \"Initial thoughts\" to plan the way you'll proceed to use the tools X, Y, and Z.\n\nOnce you've executed your initial plan, call the tool \"Additional thoughts\" to check in with the results and decide if you need to further use tools X, Y, and Z or if you're ready to answer the user.\n"
}
},
"typeVersion": 2.2
},
{
"id": "1cdbe2f6-5b78-4c5c-8a76-2ddd2b126543",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
48,
112
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "dMiSy27YCK6c6rra",
"name": "Duv's OpenAI"
}
},
"typeVersion": 1.2
},
{
"id": "99fb74bf-dae8-4ae4-9f35-ad5c95d5a97d",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
208,
112
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "74bd5f99-5e02-41b9-961e-7d4654df47a4",
"name": "初始想法",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
448,
224
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "KNxyzmWuqSCK1GUR",
"cachedResultName": "TEMPLATE - AI agent with multiple thinking tools"
},
"description": "始终通过调用此工具开始您的流程,写下初始想法并规划回答用户查询的方式。",
"workflowInputs": {
"value": {
"Thoughts": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Thoughts', `Write initial thoughts very concisely (be token efficient, just list some thoughts) on the best ways to go about the user query.`, 'string') }}"
},
"schema": [
{
"id": "Thoughts",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Thoughts",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Thoughts"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "81f7dad8-01d4-4f26-be4b-250835f97a6b",
"name": "附加想法",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
624,
224
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "KNxyzmWuqSCK1GUR",
"cachedResultName": "TEMPLATE - AI agent with multiple thinking tools"
},
"description": "在...之后调用此工具进行检查,并决定在最终能够回答用户查询之前是否需要其他步骤。",
"workflowInputs": {
"value": {
"Thoughts": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Thoughts', `Write your thoughts very concisely (be token efficient, just list some thoughts) on the best ways to go about the user query.`, 'string') }}"
},
"schema": [
{
"id": "Thoughts",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Thoughts",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Thoughts"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "6912f166-d7a7-441c-92e6-578f3f9a81e5",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-608,
-96
],
"parameters": {
"width": 480,
"height": 768,
"content": "# 高级代理推理框架"
},
"typeVersion": 1
},
{
"id": "3dd09d82-c7d3-40e9-bad6-3b64729142e5",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
384,
96
],
"parameters": {
"color": 7,
"width": 400,
"height": 240,
"content": "## 您的思考工具"
},
"typeVersion": 1
},
{
"id": "7fdd3183-a348-4c1b-b1ee-5ceef90bfc07",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-16,
352
],
"parameters": {
"color": 7,
"width": 304,
"height": 320,
"content": "## 子工作流"
},
"typeVersion": 1
},
{
"id": "3eab469a-d1d3-4da2-be78-c938f85dc943",
"name": "思考子工作流",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
80,
512
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "Thoughts"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "96cb61dc-146f-4c34-bec5-6d150d2c2bd7",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
192,
-240
],
"parameters": {
"color": 7,
"width": 400,
"height": 240,
"content": "## 代理"
},
"typeVersion": 1
}
],
"connections": {
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Initial thoughts": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Additional thoughts": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工程, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用GPT-4创建播放列表和控制Spotify播放器
通过GPT-4创建播放列表并控制Spotify播放器
Set
Code
Spotify
+11
29 节点Guillaume Duvernay
个人效率
使用Claude Opus 4从自然语言生成完整工作流
使用Claude Opus 4从自然语言生成完整工作流
N8n
Set
Google Drive
+9
17 节点Electrabot
工程
构建基于Supabase和GPT-5的高级多查询RAG系统
构建基于Supabase和GPT-5的高级多查询RAG系统
If
Set
Filter
+13
22 节点Guillaume Duvernay
AI RAG 检索增强
AI智能助手与Airtable对话及数据分析
AI智能助手与Airtable对话及数据分析
If
Set
Merge
+12
41 节点Mark Shcherbakov
工程
我的工作流
通过GPT-4、Google文档和Mermaid图表自动化个性化Upwork提案
Set
Google Docs
Google Drive
+8
23 节点Nick Saraev
客户培育
创建具有GPT-4o聊天界面和可视化报告的交互式Snowflake数据浏览器
创建具有GPT-4o聊天界面和可视化报告的交互式Snowflake数据浏览器
If
Set
Webhook
+11
28 节点Mark Shcherbakov
内部知识库