🗼 AI驱动的供应链控制塔(使用BigQuery和GPT-4o)
中级
这是一个AI, IT Ops领域的自动化工作流,包含 11 个节点。主要使用 Code, GoogleBigQuery, Agent, ChatTrigger, LmChatOpenAi 等节点,结合人工智能技术实现智能自动化。 🗼 AI驱动的供应链控制塔(使用BigQuery和GPT-4o)
前置要求
- •OpenAI API Key
使用的节点 (11)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "6a5e68bcca67c4cdb3e0b698d01739aea084e1ec06e551db64aeff43d174cb23"
},
"nodes": [
{
"id": "53b36910-966f-45ba-a425-a3260a55059f",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
340,
480
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "177235e8-c925-43d0-9695-10f072e26350",
"name": "AI Control Tower Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
380,
240
],
"parameters": {
"options": {
"systemMessage": "=You are an AI-powered SQL assistant specialized in supply chain analytics. \nYour role is to execute SQL queries on BigQuery and return only the results in a structured format.\n\nToday we are May 31, 2021.\n\n### **Behavior & Rules**\n1️⃣ **Query Execution:**\n - Your only task is to process user requests and return **direct results** from BigQuery.\n - Do **not** display the SQL query.\n - Only return structured **data** as output.\n\n2️⃣ **Data Presentation:**\n - Format the results as a **table** whenever possible.\n - If results are numerical (counts, percentages, aggregates), return them **clearly and concisely**.\n - If results contain multiple rows, return **only the first 10** for preview, unless the user specifies otherwise.\n\n3️⃣ **Handling Large Datasets:**\n - If the user asks for many rows, show the first **100 rows max** unless specified.\n - Provide a **summary** when dealing with large data instead of showing everything.\n\n4️⃣ **Response Format:**\n - ✅ **For counts & metrics:** \n `\"There were 5,432 delayed shipments in the last 21 days.\"`\n - ✅ **For tables:** \n | ShipmentID | City | Store | Order Date | Delivery Date | On Time? |\n |-----------|-------|--------|------------|--------------|----------|\n | 12345 | NYC | ST1 | 2024-03-10 | 2024-03-15 | No |\n | 67890 | Paris | ST4 | 2024-03-11 | 2024-03-16 | Yes |\n\n5️⃣ **Clarifying Unclear Requests:**\n - If the user request is **too broad**, ask for clarification instead of running an expensive query.\n\n---\n\n### Schema Awareness\nAll SQL queries must use the BigQuery table: \n`transport.shipments` \n\nThis table includes fields such as:\n- `Shipment ID`, `City`, `Store`, `Order Date`, `Delivery Date`, `On Time Delivery`\n- As well as operational timestamps: `Transmission`, `Loading`, `Airport Arrival`, etc.\n- And status flags: `Transmission OnTime`, `Loading OnTime`, `Airport OnTime`, `Store Open`\n\nUse these fields appropriately when analyzing shipment performance.\n\n---\n\n### Tool Usage Instruction (for \"bigquery_tool\")\n\nWhenever you need to run a SQL query, use the tool called `bigquery_tool`.\n\nYou must provide the query in the following format:\n```json\n{\n \"query\": \"SELECT COUNT(*) FROM `transport.shipments` WHERE `On Time Delivery` = FALSE\"\n}\n"
}
},
"typeVersion": 1.8
},
{
"id": "5366cc5f-85d3-44d2-9b1b-62febfcb44e3",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-100,
-120
],
"parameters": {
"color": 7,
"width": 200,
"height": 520,
"content": "### 1. 带聊天功能的工作流触发器"
},
"typeVersion": 1
},
{
"id": "4218a062-12f8-437d-ab22-5a653a3089b2",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
140,
-120
],
"parameters": {
"color": 7,
"width": 700,
"height": 740,
"content": "### 2. 配备查询工具的 AI Agent"
},
"typeVersion": 1
},
{
"id": "c5967f58-00e8-4f03-9110-913547f7ab9c",
"name": "调用查询工具",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
640,
440
],
"parameters": {
"name": "bigquery_tool",
"workflowId": {
"__rl": true,
"mode": "list",
"value": "4Os7DoxHjFuTwWio",
"cachedResultName": "🔨 Big Query Tool"
},
"description": "=使用此工具运行 SQL 查询并从 BigQuery 数据库获取结果。",
"workflowInputs": {
"value": {
"query": "={{ $fromAI(\"query\", \"SQL query to run\") }}"
},
"schema": [
{
"id": "query",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"query"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2
},
{
"id": "429813c8-b07f-4551-aeea-1744a1225449",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
-120
],
"parameters": {
"width": 760,
"height": 460,
"content": "### 3. Big Query 工作流"
},
"typeVersion": 1
},
{
"id": "bede0624-8923-4af0-8adc-8be22d556066",
"name": "Query Database",
"type": "n8n-nodes-base.googleBigQuery",
"position": [
1520,
180
],
"parameters": {
"options": {},
"sqlQuery": "={{ $json.query }}",
"projectId": {
"__rl": true,
"mode": "list",
"value": "=",
"cachedResultUrl": "=",
"cachedResultName": "="
}
},
"notesInFlow": true,
"typeVersion": 2.1
},
{
"id": "137e4dbc-db8d-4ec7-a3e0-478dde6ef27c",
"name": "Trigger Executed by the AI Tool",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
960,
180
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "query"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "42a2801e-582e-4340-83af-ef0041eab4f9",
"name": "Sanitising the Query",
"type": "n8n-nodes-base.code",
"position": [
1240,
180
],
"parameters": {
"jsCode": "return [\n {\n json: {\n query: $input.first().json.query.replace(/```sql|```/g, \"\").trim()\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "7c86fda0-116c-47ad-aaf5-8b83d2c083c6",
"name": "聊天记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
480,
480
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "e1408ac1-24da-4d38-8fdf-c110a54d3f55",
"name": "Chat with the User",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-60,
240
],
"webhookId": "ee7c418b-d7d6-41f9-8e87-0f71b8ae1cf9",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "bc49829b-45f2-4910-9c37-907271982f14",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
380
],
"parameters": {
"width": 780,
"height": 540,
"content": "### 4. Do you need more details?\nFind a step-by-step guide in this tutorial\n\n[🎥 Watch My Tutorial](https://www.loom.com/share/50271f9d50214d7184830985497a75ec?sid=d0c410dc-29f1-488f-b89a-4011de0ded07)"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Chat Memory": {
"ai_memory": [
[
{
"node": "AI Control Tower Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Call Query Tool": {
"ai_tool": [
[
{
"node": "AI Control Tower Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Control Tower Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Chat with the User": {
"main": [
[
{
"node": "AI Control Tower Agent",
"type": "main",
"index": 0
}
]
]
},
"Sanitising the Query": {
"main": [
[
{
"node": "Query Database",
"type": "main",
"index": 0
}
]
]
},
"Trigger Executed by the AI Tool": {
"main": [
[
{
"node": "Sanitising the Query",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于AI的Nextcloud文档聊天系统,使用LangChain和OpenAI
基于AI的Nextcloud文档聊天系统,使用LangChain和OpenAI
If
Set
Code
+12
21 节点johappel
人工智能
[AOE] 收件箱和日历管理 Agent
使用 Gmail、Google Calendar 和 GPT-4o AI 自动化邮件与日历管理
Code
Gmail
Gmail Tool
+17
38 节点AOE Agent Lab
人工智能
构建自定义n8n工作流MCP服务器
构建自定义n8n工作流MCP服务器
If
N8n
Set
+15
46 节点Jimleuk
其他
基于语义和结构化RAG的电子邮件聊天机器人,使用Telegram和Pgvector
使用Telegram、Mistral和Pgvector的RAG技术与您的邮件历史对话
If
Set
Code
+12
20 节点Alfonso Corretti
客户支持
终极个人 Todoist 智能助手
使用Todoist和GPT-4o进行自然语言任务管理
Todoist Tool
Agent
Http Request Tool
+6
35 节点max e
人工智能
AI智能体:数秒内精准匹配LinkedIn人脉
AI智能体:数秒内精准匹配LinkedIn人脉
Set
Code
Split Out
+10
15 节点Badr
人工智能
工作流信息
难度等级
中级
节点数量11
分类2
节点类型9
作者
Samir Saci
@samirsaciAutomation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci
外部链接
在 n8n.io 查看 →
分享此工作流