8
n8n 中文网amn8n.com

创建用于实时Google表格分析的GPT-4数据分析聊天机器人

高级

这是一个AI Chatbot, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Merge, Aggregate, GoogleSheets, Agent, ChatTrigger 等节点。 创建用于实时Google表格分析的GPT-4数据分析聊天机器人

前置要求
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "c2a31cd3-1cb9-4268-b587-cf5f0462e4a4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        960,
        600
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "MGwGMKEkdcjzlYCw",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6253a41e-be2d-4938-8658-1798f76282b7",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -200,
        400
      ],
      "webhookId": "e4a9a147-7a38-4027-b869-bdb13a89dc30",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "b5db715e-c2a9-46af-a544-6ccf32f3cd11",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        720,
        400
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.1
    },
    {
      "id": "c7317d56-e218-4544-b0fa-787280ea6ff3",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1120,
        600
      ],
      "parameters": {
        "sessionKey": "={{ $('When chat message received').item.json.sessionId }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "0938975c-2dad-41a8-ae91-b61f7bea50b7",
      "name": "Data Analyst AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        960,
        400
      ],
      "parameters": {
        "text": "=User Input:\n{{ $('When chat message received').item.json.chatInput }}",
        "options": {
          "systemMessage": "=You are a helpful AI Data Analyst.  \nUse the provided JSON data to analyze and answer questions.  \n\nProducts:  \n{{ $json.products.map(item => item).toJsonString() }}  \n\nCustomers:  \n{{ $json.customers.map(item => item).toJsonString() }}  \n\nOrders:  \n{{ $json.orders.map(item => item).toJsonString() }}  \n\nAlways use the data above when performing analysis.  \n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "96c91c7f-9111-43fc-b56d-2811ba18fdc9",
      "name": "Google Sheets - Get Products Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        200
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Products"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/13QGuASZJE2MtpTvX83OUCz_dn-WRy4DggWLy5HjBvJk/edit?gid=1076558389#gid=1076558389"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "f6594bb6-8b89-41cc-8e72-8a970af4c982",
      "name": "Google Sheets - Get Customers Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        400
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Customers"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/13QGuASZJE2MtpTvX83OUCz_dn-WRy4DggWLy5HjBvJk/edit?gid=1076558389#gid=1076558389"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "36deeb5c-7e7e-4ee2-b0a2-97e8c4b33c9a",
      "name": "Google Sheets - Get Orders Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        620
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/13QGuASZJE2MtpTvX83OUCz_dn-WRy4DggWLy5HjBvJk/edit?gid=1076558389#gid=1076558389"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "67ddb3e6-dacb-413c-afc4-832b6c6a2c53",
      "name": "Aggregate Data 1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        400,
        200
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "products"
      },
      "typeVersion": 1
    },
    {
      "id": "847c0e0b-e519-4eaf-be0a-992d8f02cb18",
      "name": "Aggregate Data 2",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        400,
        400
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "customers"
      },
      "typeVersion": 1
    },
    {
      "id": "e72588a6-eac5-4015-a302-ff0a96747a71",
      "name": "Aggregate Data 3",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        400,
        640
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "orders"
      },
      "typeVersion": 1
    },
    {
      "id": "ca4b8f48-338c-480e-b0ca-f424044c50f3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        -40
      ],
      "parameters": {
        "color": 4,
        "width": 300,
        "height": 860,
        "content": "## Google Sheet - Get Data  \nUpdate the document URL  \nUpdate the sheet name  \nAdjust the number of Google Sheets nodes based on your use case  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "af0947bb-3e99-4eac-8186-32a506581366",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -780,
        140
      ],
      "parameters": {
        "color": 4,
        "width": 520,
        "height": 300,
        "content": "Workflow Configurations:  \n- Update the Google Sheets document ID in all Google Sheets nodes to point to your data source based on your use case  \n- Example Google Sheets template you can copy: https://docs.google.com/spreadsheets/d/1-QTFO3TbGFjtYOMUfZb0aY66J_8G-R0Rb0JHLWrEZ90/edit?gid=0#gid=0  \n- Configure the sheet names to match your Google Sheets structure  \n- Adjust the AI Agent system message to reflect your specific data schema and analysis requirements  \n- Customize the chat trigger webhook ID for your specific implementation  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "31d2d863-2087-4de6-b7d7-b845b44e40ef",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        860
      ],
      "parameters": {
        "color": 4,
        "width": 880,
        "height": 320,
        "content": "## 🤖 Build a Smart AI Data Analyst Chatbot with Google Sheet and GPT-5\n\nWhat This Template Does:\n\n- Creates an intelligent chatbot that can analyze data from Google Sheets in real time  \n- Fetches live data from all Google Sheets whenever a chat message is received  \n- Uses OpenAI's model to provide intelligent data analysis and insights  \n- Maintains conversation memory to provide context-aware responses across chat sessions  \n- Combines multiple data sources to provide comprehensive business intelligence answers  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "39c68ef9-71c2-45a1-99e3-b88576d16c45",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        860
      ],
      "parameters": {
        "color": 4,
        "width": 820,
        "height": 420,
        "content": "## 📋 WORKFLOW PROCESS OVERVIEW\n\nStep 1: 💬 Chat Trigger receives incoming chat messages with session ID tracking  \nStep 2: 📊 Data Retrieval (Parallel Processing)  \nStep 3: 🔄 Data Aggregation combines data from all sources  \nStep 4: 🤝 Merge Node combines all aggregated data streams into a single data object  \nStep 5: 🧠 AI Analysis processes user input using:  \n - OpenAI Model for intelligent responses  \n - Simple Memory maintains conversation context using session ID  \n - Data Analyst AI Agent analyzes the combined data and generates insights based on user queries  \nStep 6: 📤 Response delivers analytical insights, charts, summaries, or answers back to the chat interface  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "1ef90da5-29e6-4b21-9045-3db6d4bb7f78",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1400,
        120
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 760,
        "content": "# 👋 Hi, I’m Billy\n\nI help businesses build **n8n workflows** & **AI automation projects**.  \nNeed help with n8n or AI Automation projects? \nContact me and let’s build your automation together.\n\n📩 **Email:** billychartanto@gmail.com  \n🤝 **n8n Creator:** [n8n.io/creators/billy](https://n8n.io/creators/billy/)\n🌐 **My n8n Projects:** [billychristi.com/n8n](https://www.billychristi.com/n8n)  \n\n\n\n---\n💡 Feel free to get in touch if you’d like help on your next automation project or if you have any feedback or thoughts to share.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "27d66d12-5a60-45c8-a175-03fdea4db01d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        200
      ],
      "parameters": {
        "color": 4,
        "width": 460,
        "height": 640,
        "content": "## Data Analyst AI Agent  \nThis is where all data is processed based on user input  \n\nConfiguration:  \nUpdate the system message prompt data sources based on your use case  \n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Data Analyst AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Data Analyst AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Data 1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Data 2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Aggregate Data 3": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Data Analyst AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Google Sheets - Get Orders Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets - Get Products Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets - Get Customers Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Get Orders Data": {
      "main": [
        [
          {
            "node": "Aggregate Data 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Get Products Data": {
      "main": [
        [
          {
            "node": "Aggregate Data 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets - Get Customers Data": {
      "main": [
        [
          {
            "node": "Aggregate Data 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - AI 聊天机器人, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量17
分类2
节点类型8
难度说明

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

作者
Billy Christi

Billy Christi

@billy

I build scalable automation systems with n8n to help businesses save time and cut costs. 💼 n8n expert available for new projects 📩 billychartanto@gmail.com

外部链接
在 n8n.io 查看

分享此工作流