{
  "name": "Query your PostgreSQL data in plain English with GPT-4o-mini",
  "nodes": [
    {
      "id": "d8e5561d-5ac8-4cc0-970e-a1bb9238b9bd",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -768,
        176
      ]
    },
    {
      "id": "ab7f525e-93ba-441d-8b94-d5a4260e81d3",
      "name": "Manage Table Name",
      "type": "n8n-nodes-base.code",
      "position": [
        -544,
        176
      ]
    },
    {
      "id": "03d7146e-1009-4ccf-90e0-6a241d04c556",
      "name": "Need Schema?",
      "type": "n8n-nodes-base.if",
      "position": [
        -320,
        176
      ]
    },
    {
      "id": "ee74c609-c31a-49bf-928a-c3da7bd7a8ef",
      "name": "Fetch Schema",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -96,
        80
      ]
    },
    {
      "id": "a245eb4f-de7e-4e2c-9e2b-34b947b51d28",
      "name": "Format Schema",
      "type": "n8n-nodes-base.code",
      "position": [
        128,
        80
      ]
    },
    {
      "id": "b1385865-6234-4727-a5fa-0a010ef53b8e",
      "name": "Empty Schema",
      "type": "n8n-nodes-base.set",
      "position": [
        128,
        272
      ]
    },
    {
      "id": "448e26ba-7e19-4b7a-8f3f-31f557743264",
      "name": "Unified Analytics Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        472,
        176
      ]
    },
    {
      "id": "22f7dbf6-d64b-4951-ac16-2f066f3e2d6d",
      "name": "OpenAI GPT-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        352,
        400
      ]
    },
    {
      "id": "a8747d73-262a-4a18-a262-d01490f64b94",
      "name": "Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        480,
        400
      ]
    },
    {
      "id": "cee02d80-045a-4cc9-abe6-44cb364130f7",
      "name": "Execute SQL Query",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        608,
        400
      ]
    },
    {
      "id": "8ab38bf8-6dc2-4766-9ccf-16233bb46dd9",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -640,
        688
      ]
    },
    {
      "id": "627af582-602e-4043-894e-a58db835c379",
      "name": "⚙️ Config (Sync)",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        688
      ]
    },
    {
      "id": "54eaaa6e-55a6-478f-b769-621ab8ab5260",
      "name": "Fetch Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        32,
        688
      ]
    },
    {
      "id": "6e2faa14-2ede-45d1-aad6-56064f6ae6f8",
      "name": "Insert Rows to Postgres",
      "type": "n8n-nodes-base.postgres",
      "position": [
        256,
        688
      ]
    },
    {
      "id": "7c0df0b0-8986-4537-a9a0-cdb2c4907c2b",
      "name": "Truncate Table",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -192,
        688
      ]
    },
    {
      "id": "3efea6d1-50fb-47a4-8bc1-ca2d58184a20",
      "name": "QuickChart",
      "type": "n8n-nodes-base.quickChartTool",
      "position": [
        736,
        400
      ]
    },
    {
      "id": "2199f7a4-bf7f-4459-82df-0bc099f54453",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        -48
      ],
      "parameters": {
        "width": 416,
        "height": 784,
        "content": "This workflow lets you query your PostgreSQL database using natural language.\n\nInstead of writing SQL manually or exporting data, users can simply type questions and receive structured answers with ch"
      }
    },
    {
      "id": "a884bdb7-b101-46d9-a0b5-2c57ddbe640c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -792,
        48
      ],
      "parameters": {
        "width": 368,
        "height": 288,
        "content": "Handles user input and session tracking  \nStores table name to avoid repeated input"
      }
    },
    {
      "id": "7a5c3be7-d047-4414-9e23-07e641d23184",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -16
      ],
      "parameters": {
        "width": 624,
        "height": 448,
        "content": "Handles user input and session tracking  \nStores table name to avoid repeated input"
      }
    },
    {
      "id": "f94c9c4d-dfca-4058-9bd9-f91368d28040",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        16
      ],
      "parameters": {
        "width": 624,
        "height": 528,
        "content": "Generates SQL from natural language  \nExecutes queries and formats results\nCreates charts from query results  \nHelps interpret data visually"
      }
    },
    {
      "id": "a82e2581-bdce-43ed-89c5-721394753221",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        592
      ],
      "parameters": {
        "width": 1184,
        "height": 288,
        "content": "Loads data from Google Sheets into PostgreSQL  \nUseful for scheduled or batch updates"
      }
    },
    {
      "id": "12a03ce6-1ce8-4a0a-a2a6-c30f9bcea08e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        608
      ],
      "parameters": {
        "width": null,
        "height": 240,
        "content": "⚠️ Truncate Table will delete existing data  \nDisable or remove if not required"
      }
    }
  ],
  "connections": {
    "QuickChart": {
      "ai_tool": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "Manage Table Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Empty Schema": {
      "main": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Schema": {
      "main": [
        [
          {
            "node": "Format Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Need Schema?": {
      "main": [
        [
          {
            "node": "Fetch Schema",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Empty Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Schema": {
      "main": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "⚙️ Config (Sync)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Truncate Table": {
      "main": [
        [
          {
            "node": "Fetch Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute SQL Query": {
      "ai_tool": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Manage Table Name": {
      "main": [
        [
          {
            "node": "Need Schema?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Google Sheet": {
      "main": [
        [
          {
            "node": "Insert Rows to Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o-mini": {
      "ai_languageModel": [
        [
          {
            "node": "Unified Analytics Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "⚙️ Config (Sync)": {
      "main": [
        [
          {
            "node": "Truncate Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}