8
n8n 中文网amn8n.com

✨📊 用于Postgres/Supabase数据库和QuickCharts + 工具路由器的多AI代理聊天机器人

高级

这是一个AI领域的自动化工作流,包含 40 个节点。主要使用 Set, Switch, HttpRequest, PostgresTool, Agent 等节点,结合人工智能技术实现智能自动化。 ✨📊 用于Postgres/Supabase数据库和QuickCharts + 工具路由器的多AI代理聊天机器人

前置要求
  • 可能需要目标 API 的认证凭证
  • PostgreSQL 数据库连接信息
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Q63cSgFlcqz291ec",
  "meta": {
    "instanceId": "31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef",
    "templateCredsSetupCompleted": true
  },
  "name": "✨📊用于 Postgres/Supabase 数据库和 QuickCharts + 工具路由器的多 AI 代理聊天机器人",
  "tags": [],
  "nodes": [
    {
      "id": "3a332532-a56e-42f5-a114-4a7e138b5e0f",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -180,
        -1420
      ],
      "webhookId": "faddb40a-7048-4398-a0f9-d239a19c32ce",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "6c707ee7-95e9-4ebd-9373-a2dac0ea73a7",
      "name": "执行 SQL 查询",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        460,
        -500
      ],
      "parameters": {
        "query": "{{ $fromAI(\"sql_query\", \"SQL Query\") }}",
        "options": {},
        "operation": "executeQuery",
        "descriptionType": "manual",
        "toolDescription": "Use this tool to query the database with SQL queries"
      },
      "credentials": {
        "postgres": {
          "id": "wZnget4L3P3bnlfh",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "1d5572e1-de5a-4e67-8ba1-82196bd62e9b",
      "name": "当由其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -480,
        -360
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "user_prompt"
            },
            {
              "name": "route"
            },
            {
              "name": "db_records"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e3caa1b3-7bdb-43c1-a749-74ae02912d84",
      "name": "query_db_tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        720,
        -1100
      ],
      "parameters": {
        "name": "query_database_tool",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{  $workflow.id }}"
        },
        "description": "使用此工具查询数据库",
        "workflowInputs": {
          "value": {
            "route": "query_database_tool",
            "user_prompt": "={{ $('When chat message received').item.json.chatInput }}"
          },
          "schema": [
            {
              "id": "user_prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user_prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "route",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "route",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user_prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2
    },
    {
      "id": "594e6fd3-084a-4100-ac16-1cc4068e03c1",
      "name": "generate_quickchart_tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        980,
        -1100
      ],
      "parameters": {
        "name": "generate_chart_tool",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{  $workflow.id }}"
        },
        "description": "使用此工具通过 QuickChart 生成图表",
        "workflowInputs": {
          "value": {
            "route": "generate_chart_tool",
            "db_records": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('db_records', `The database records`, 'string') }}",
            "user_prompt": "={{ $('When chat message received').item.json.chatInput }}"
          },
          "schema": [
            {
              "id": "user_prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user_prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "route",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "route",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "db_records",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "db_records",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user_prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2
    },
    {
      "id": "580426ac-0fb7-4f14-af7b-e497b7cb08f8",
      "name": "创建 QuickChart",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        780,
        -140
      ],
      "parameters": {
        "url": "={{ encodeURI($json.url) }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "b7085357-ebe9-4564-868d-b31fc2e9734a",
      "name": "QuickChart 对象模式",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        460,
        140
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"type\": \"bar\",\n  \"data\": {\n    \"labels\": [\"R270684\", \"R274295\", \"R276352\", \"R277914\", \"R280108\"],\n    \"datasets\": [\n      {\n        \"label\": \"List Price\",\n        \"data\": [2149000, 924900, 924900, 1288000, 1198000],\n        \"backgroundColor\": \"#FF6384\"\n      },\n      {\n        \"label\": \"Days On Market\",\n        \"data\": [101, 91, 123, 136, 185],\n        \"backgroundColor\": \"#36A2EB\"\n      }\n    ]\n  },\n  \"options\": {\n    \"scales\": {\n      \"y\": {\n        \"min\": 0,\n        \"max\": 2200000\n      }\n    }\n  }\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "b1037112-f5af-4e61-8bd1-0d9b0a9ad2e1",
      "name": "gpt-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        -1100
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "responseFormat": "text"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "jEMSvKmtYfzAkhe6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5ea5ba56-2368-4e95-a98f-2c7548a66a9b",
      "name": "gpt-4o-mini-2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "=gpt-4o-mini"
        },
        "options": {
          "responseFormat": "text"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "jEMSvKmtYfzAkhe6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4b8f9978-9d46-48f5-93ca-002ade008887",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -1500
      ],
      "parameters": {
        "color": 5,
        "width": 1100,
        "height": 600,
        "content": "## 🤖主要 AI 管理器代理"
      },
      "typeVersion": 1
    },
    {
      "id": "f6534374-cc07-429a-b27c-b38835c96465",
      "name": "🤖主要代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        -1420
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant that answers the users questions by using the tools provided.\n\n## TOOLS\n- query_database_tool: Use this tool to query the database\n- generate_chart_tool: Use this tool to generate a chart with QuickChart\n\nAlways provide the results of the database query and the link for the chart when applicable."
        }
      },
      "typeVersion": 1.7
    },
    {
      "id": "cf246e46-b3e4-4c9f-96f9-be1b91c0a3eb",
      "name": "🤖辅助 Postgres 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        -780
      ],
      "parameters": {
        "text": "={{ $json.user_prompt }}",
        "options": {
          "systemMessage": "You are a helpful assistant with tools for querying a SQL database.  Use the tools provided to query the database."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "02d741d3-4b6e-4e19-8aca-3e15175e9667",
      "name": "🤖辅助 QuickChart 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        -140
      ],
      "parameters": {
        "text": "=Your task is to generate a Chart.js configuration object with the following specifications:\n- Chart type: bar unless otherwise indicated\n- Labels: Use the ML # from each record unless otherwise indicated\n- Show bar for list price if not otherwise indicated\n- Return only the raw JSON object without code fences or explanations\n\nThis is the user prompt: {{ $json.user_prompt }}\nThis is the result of the SQL query: {{ $json.db_records }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "4f41690b-313a-4ce3-ba65-a2ce2c3ee9b9",
      "name": "🔀工具代理路由器",
      "type": "n8n-nodes-base.switch",
      "position": [
        -180,
        -360
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "🔍query",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35b1e13e-6157-48d0-85af-3cd33260eae1",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "=query_database_tool"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "📊chart",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ff5f97fb-0f18-4bf9-b16c-3d0b3bc3c7f4",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "=generate_chart_tool"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "27c30d2c-3af3-4d05-aadb-9f18751fb9ce",
      "name": "表定义",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        980,
        -500
      ],
      "parameters": {
        "query": "select\n  c.column_name,\n  c.data_type,\n  c.is_nullable,\n  c.column_default,\n  tc.constraint_type,\n  ccu.table_name AS referenced_table,\n  ccu.column_name AS referenced_column\nfrom\n  information_schema.columns c\nLEFT join\n  information_schema.key_column_usage kcu\n  ON c.table_name = kcu.table_name\n  AND c.column_name = kcu.column_name\nLEFT join\n  information_schema.table_constraints tc\n  ON kcu.constraint_name = tc.constraint_name\n  AND tc.constraint_type = 'FOREIGN KEY'\nLEFT join\n  information_schema.constraint_column_usage ccu\n  ON tc.constraint_name = ccu.constraint_name\nwhere\n  c.table_name = '{{ $fromAI(\"table_name\") }}'\n  AND c.table_schema = '{{ $fromAI(\"schema_name\") }}'\norder by\n  c.ordinal_position",
        "options": {},
        "operation": "executeQuery",
        "descriptionType": "manual",
        "toolDescription": "Use this tool to get table definition to find all columns and types"
      },
      "credentials": {
        "postgres": {
          "id": "wZnget4L3P3bnlfh",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "59dfd315-fb02-425c-a6ca-2d63167c2e24",
      "name": "Postgres 聊天记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        460,
        -1100
      ],
      "parameters": {
        "tableName": "={{ $workflow.id }}_chat_history"
      },
      "credentials": {
        "postgres": {
          "id": "wZnget4L3P3bnlfh",
          "name": "Postgres account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "81dd8b73-0809-4f30-a867-bf98ff6a80bc",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -1180
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "## QuickChart 工具"
      },
      "typeVersion": 1
    },
    {
      "id": "1a08bc08-510b-4cda-b96e-179bd3abe164",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -1180
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "## Postgres 工具"
      },
      "typeVersion": 1
    },
    {
      "id": "9cc5e958-0f93-42ad-813e-83c8b5bb126e",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -1180
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "## LLM"
      },
      "typeVersion": 1
    },
    {
      "id": "920f9fe4-e182-4159-9152-e81586ec5304",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -1180
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "## 聊天记忆"
      },
      "typeVersion": 1
    },
    {
      "id": "d2a24dce-1add-49d6-8d2f-6547fca35bfb",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -1500
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 280,
        "content": "## 👍从这里开始"
      },
      "typeVersion": 1
    },
    {
      "id": "d0df3ea6-9765-4f4d-a8f7-b2356ea1cf26",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -860
      ],
      "parameters": {
        "color": 6,
        "width": 1100,
        "height": 560,
        "content": "## ⚒️🤖辅助 Postgres 工具代理"
      },
      "typeVersion": 1
    },
    {
      "id": "fe990853-fce6-4cbe-9cc2-fc04f53742e8",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -580
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c5086736-4dfe-44a3-a5dc-6cace0593334",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -580
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "6b848863-10b2-42e4-8bd5-ed4663b9e5cb",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -580
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "75231fcf-8314-4ee6-96a7-99d842b6ee4f",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -580
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c54439c7-ccb1-41a4-ad76-8ed39f7fc5e6",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -460
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 320,
        "content": "## 工具代理路由器 🔀"
      },
      "typeVersion": 1
    },
    {
      "id": "b51ffe20-2ae4-478b-9573-fc5456935483",
      "name": "便签 12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -260
      ],
      "parameters": {
        "color": 6,
        "width": 1100,
        "height": 600,
        "content": "## ⚒️🤖辅助 QuickChart 工具代理"
      },
      "typeVersion": 1
    },
    {
      "id": "ffb9da23-f79c-4d20-81a3-656471bdda33",
      "name": "便签 13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        60
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "61532d90-1f65-48d0-a408-2e6edd9511b1",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        60
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5b125fa6-8017-437e-bb20-b9deb5d52c63",
      "name": "最终 QuickChart URL",
      "type": "n8n-nodes-base.set",
      "position": [
        980,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "63bab42a-9b9b-4756-88d2-f41cff9a1ded",
              "name": "quickchart_url",
              "type": "string",
              "value": "={{ encodeURI($json.url) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2c66055d-1ca2-40f3-a082-57232402fdd1",
      "name": "QuickChart GET URL",
      "type": "n8n-nodes-base.set",
      "position": [
        580,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d69995ae-413e-49e7-b6ec-17e9e034e4b6",
              "name": "url",
              "type": "string",
              "value": "={{ \"https://quickchart.io/chart?width=250&height=150&chart=\" + $json.output.toJsonString() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0a0f024d-24fa-43e9-bfa6-b841902b5e5e",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -540,
        -1600
      ],
      "parameters": {
        "color": 7,
        "width": 1760,
        "height": 1980,
        "content": "# ✨📊用于 Postgres/Supabase 数据库和 QuickCharts + 工具路由器的多 AI 代理聊天机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "a50b4d31-7e9e-4cd0-84b9-f4755deb6efd",
      "name": "便签 16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -1180
      ],
      "parameters": {
        "width": 540,
        "height": 240,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "3df0304a-323b-4bd4-96ce-2907367ede8d",
      "name": "便签 17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -860
      ],
      "parameters": {
        "width": 542,
        "height": 296,
        "content": "## 使用的 Postgres 工具"
      },
      "typeVersion": 1
    },
    {
      "id": "feaeaf6d-f5b8-4dbe-a39b-d07882142ead",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -40
      ],
      "parameters": {
        "width": 542,
        "height": 376,
        "content": "## 生成 Quickchart"
      },
      "typeVersion": 1
    },
    {
      "id": "6c9be4d2-46e9-44ae-8751-f4f4964323e9",
      "name": "数据库模式和表",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        720,
        -500
      ],
      "parameters": {
        "query": "SELECT \n    table_schema,\n    table_name\nFROM information_schema.tables\nWHERE table_type = 'BASE TABLE'\n    AND table_schema NOT IN ('pg_catalog', 'information_schema')\nORDER BY table_schema, table_name;",
        "options": {},
        "operation": "executeQuery",
        "descriptionType": "manual",
        "toolDescription": "Use this tool to get a list of all tables with their schema in the database"
      },
      "credentials": {
        "postgres": {
          "id": "wZnget4L3P3bnlfh",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "4e779b6f-963c-4efb-af43-bec0e5c3228c",
      "name": "gpt-40-mini-1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        -500
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "responseFormat": "text"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "jEMSvKmtYfzAkhe6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a6cc9a4e-b016-47f6-9f9f-9c77a15c2be2",
      "name": "便签 18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        180
      ],
      "parameters": {
        "width": 440,
        "height": 120,
        "content": "## QuickChart 模式"
      },
      "typeVersion": 1
    },
    {
      "id": "9855ba6a-d46b-4461-a397-02108023abc5",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        60
      ],
      "parameters": {
        "width": 440,
        "height": 100,
        "content": "## 图表尺寸"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "json": {
          "route": "generate_chart_tool",
          "db_records": "[{\"mls_num\":\"R292309\",\"list_price\":1148000},{\"mls_num\":\"R292302\",\"list_price\":1298000},{\"mls_num\":\"R294786\",\"list_price\":1280000},{\"mls_num\":\"V17840\",\"list_price\":939000},{\"mls_num\":\"V10178\",\"list_price\":420000},{\"mls_num\":\"V18007\",\"list_price\":296500},{\"mls_num\":\"V18136\",\"list_price\":379000},{\"mls_num\":\"V18643\",\"list_price\":329000},{\"mls_num\":\"V17755\",\"list_price\":236000},{\"mls_num\":\"V19126\",\"list_price\":245500}]",
          "user_prompt": "provide a bar chart showing mls# and list price"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9781f576-38ef-4e18-9fbe-8383565cb032",
  "connections": {
    "gpt-4o-mini": {
      "ai_languageModel": [
        [
          {
            "node": "🤖Primary Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "gpt-40-mini-1": {
      "ai_languageModel": [
        [
          {
            "node": "🤖Secondary Postgres Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "gpt-4o-mini-2": {
      "ai_languageModel": [
        [
          {
            "node": "🤖Secondary QuickChart Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "query_db_tool": {
      "ai_tool": [
        [
          {
            "node": "🤖Primary Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create QuickChart": {
      "main": [
        [
          {
            "node": "Final QuickChart URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute SQL Query": {
      "ai_tool": [
        [
          {
            "node": "🤖Secondary Postgres Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Table Definitions": {
      "ai_tool": [
        [
          {
            "node": "🤖Secondary Postgres Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "🤖Primary Agent": {
      "main": [
        []
      ]
    },
    "QuickChart GET URL": {
      "main": [
        [
          {
            "node": "Create QuickChart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DB Schema and Tables": {
      "ai_tool": [
        [
          {
            "node": "🤖Secondary Postgres Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "🤖Primary Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "🔀Tool Agent Router": {
      "main": [
        [
          {
            "node": "🤖Secondary Postgres Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🤖Secondary QuickChart Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuickChart Object Schema": {
      "ai_outputParser": [
        [
          {
            "node": "🤖Secondary QuickChart Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "generate_quickchart_tool": {
      "ai_tool": [
        [
          {
            "node": "🤖Primary Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "🤖Primary Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🤖Secondary Postgres Agent": {
      "main": [
        []
      ]
    },
    "🤖Secondary QuickChart Agent": {
      "main": [
        [
          {
            "node": "QuickChart GET URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "🔀Tool Agent Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量40
分类1
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Joseph LePage

Joseph LePage

@joe

As an AI Automation consultant based in Canada, I partner with forward-thinking organizations to implement AI solutions that streamline operations and drive growth.

外部链接
在 n8n.io 查看

分享此工作流