{
  "nodes": [
    {
      "id": "87d41f39-b0a6-45d3-bc21-ed6aaf08570e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        900,
        640
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1cb11e8a-33c4-4b9f-8d90-dcb0bac92b11",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -260,
        440
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "20c44d02-1d9a-4da9-a46b-ea57701e0fba",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        660,
        440
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.1
    },
    {
      "id": "93eb5629-69cd-4a55-9645-ed2fff2f0f3d",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1060,
        640
      ],
      "parameters": {
        "sessionKey": "={{ $('When chat message received').item.json.sessionId }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7a94bff4-a2b7-4e4f-b537-69c9b5ef60c6",
      "name": "Data Analyst AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        900,
        440
      ],
      "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": "5bfb7492-536a-4955-aab7-d1370aeece21",
      "name": "Google Sheets - Get Products Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        100,
        240
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "f2eca335-fc51-47be-a6a1-926294a78fa6",
      "name": "Google Sheets - Get Customers Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        100,
        440
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2f1e8c90-5a6c-47b3-8ff5-96d27ad9449b",
      "name": "Google Sheets - Get Orders Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        100,
        660
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2eacff6f-3b4d-47c1-9d0f-1212b7cea3e1",
      "name": "Aggregate Data 1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        340,
        240
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "products"
      },
      "typeVersion": 1
    },
    {
      "id": "88b8bfa3-fa76-4327-8ff7-0d0b9f000900",
      "name": "Aggregate Data 2",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        340,
        440
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "customers"
      },
      "typeVersion": 1
    },
    {
      "id": "ec40b643-450d-4d5e-ae8d-275dfca8b0b9",
      "name": "Aggregate Data 3",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        340,
        680
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "orders"
      },
      "typeVersion": 1
    },
    {
      "id": "4dd3dffe-725c-4ab6-b550-88275744e094",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "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": "6789d7a7-2843-4421-b9d1-7c36f365332f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        180
      ],
      "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": "49100744-0fc9-43a2-a2e7-140401aa1fd4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -860,
        900
      ],
      "parameters": {
        "color": 4,
        "width": 880,
        "height": 320,
        "content": "## \ud83e\udd16 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": "ccf844d8-1e4c-41b5-9f30-77138d915e40",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        900
      ],
      "parameters": {
        "color": 4,
        "width": 820,
        "height": 420,
        "content": "## \ud83d\udccb WORKFLOW PROCESS OVERVIEW\n\nStep 1: \ud83d\udcac Chat Trigger receives incoming chat messages with session ID tracking  \nStep 2: \ud83d\udcca Data Retrieval (Parallel Processing)  \nStep 3: \ud83d\udd04 Data Aggregation combines data from all sources  \nStep 4: \ud83e\udd1d Merge Node combines all aggregated data streams into a single data object  \nStep 5: \ud83e\udde0 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: \ud83d\udce4 Response delivers analytical insights, charts, summaries, or answers back to the chat interface  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "b7f3938e-81c0-4d31-a8e0-deb2e5608745",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        240
      ],
      "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
    },
    {
      "id": "5eaf9e5f-9531-42df-9cd0-01e4418c9987",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        180
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 760,
        "content": "# \ud83d\udc4b Hi, I\u2019m Billy\n![My Photo](https://i.ibb.co/Gvn63Bzc/Billy-Christi-AI-Automation.jpg)\nI help businesses build **n8n workflows** & **AI automation projects**.  \nNeed help with n8n or AI Automation projects? \nContact me and let\u2019s build your automation together.\n\n\ud83d\udce9 **Email:** billychartanto@gmail.com  \n\ud83e\udd1d **n8n Creator:** [n8n.io/creators/billy](https://n8n.io/creators/billy/)\n\ud83c\udf10 **My n8n Projects:** [billychristi.com/n8n](https://www.billychristi.com/n8n)  \n\n\n\n---\n\ud83d\udca1 Feel free to get in touch if you\u2019d like help on your next automation project or if you have any feedback or thoughts to share.\n"
      },
      "typeVersion": 1
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}