AutomationFlowsAI & RAG › Conversing with Data: Transforming Text Into Sql Queries and Visual Curves

Conversing with Data: Transforming Text Into Sql Queries and Visual Curves

Byhippolyte-hu @hippolyte-hu on n8n.io

This workflow enables users to interact with a PostgreSQL database using natural language. It translates text inputs into SQL queries, retrieves the corresponding data, and generates visualizations using QuickChart, facilitating seamless data analysis without manual query…

Chat trigger trigger★★★★★ complexityAI-powered36 nodesMemory Buffer WindowRead Write FileChat TriggerAgentPostgresOutput Parser StructuredOpenAI Chat
AI & RAG Trigger: Chat trigger Nodes: 36 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #3497 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "mLHcEKvtCu6m9nYi",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Conversing with Data: Transforming Text into SQL Queries and Visual Curves",
  "tags": [
    {
      "id": "xSQPh84nO2kyMj3e",
      "name": "Talk to data",
      "createdAt": "2025-02-25T10:55:43.575Z",
      "updatedAt": "2025-02-25T10:55:43.575Z"
    }
  ],
  "nodes": [
    {
      "id": "5207b91b-5a29-4786-93e2-c7ba4bd1d0f1",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        340,
        360
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "8571a134-1a79-4858-aa22-82a037a3a5f8",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1080,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "967fd040-bb82-4e97-a979-b1e91ef54b8f",
      "name": "Add table name to output",
      "type": "n8n-nodes-base.set",
      "position": [
        -380,
        -60
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "80d47d3e-476e-43fd-a021-609cdad537c8",
      "name": "Save file locally",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -40,
        -60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8e715321-38a3-4ba6-abac-efe2ad54a039",
      "name": "Extract data from file",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -360,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d0f9eb57-2226-4b4a-b7e7-b09074f5c410",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -860,
        460
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "b05e11f0-f957-4067-85fc-35bded780b59",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        220,
        140
      ],
      "parameters": {},
      "typeVersion": 1.6
    },
    {
      "id": "f91029ec-27e5-4f1d-aec8-711ef5a7e0e4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -340
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "95f41622-0ff4-4841-a83d-265864599f2f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -320
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "b12dbb8a-48fe-4627-b209-916191aef4e6",
      "name": "When clicking \"Test workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -900,
        -60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3044a292-9596-40dd-96a5-caeed0204630",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        180
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a6691f03-8688-4844-85be-b4344e9010bf",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -320
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "002bf810-5408-40a1-a05d-9bdcab64a14c",
      "name": "Combine schema data and chat input",
      "type": "n8n-nodes-base.set",
      "position": [
        -120,
        460
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "64b73d55-e01a-4777-a07c-6fb047d22666",
      "name": "Load the schema from the local file",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -620,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c016cffe-669b-418f-818f-cb3692c7dcdb",
      "name": "Extract SQL query",
      "type": "n8n-nodes-base.set",
      "position": [
        680,
        380
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "3a9d2623-751d-4b62-9fb7-68d5d9c8facf",
      "name": "Check if query exists",
      "type": "n8n-nodes-base.if",
      "position": [
        840,
        380
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "552385b5-1086-419d-b0b8-f7fa2479c13f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "4ea865a5-7988-4563-9d5a-a7f4a4f9c31f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0a25db4f-cc81-46f1-93cb-9e3d4028516d",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        560
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "66492a65-1553-4286-80ea-d03e631a0995",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "73839265-f77a-4856-b1fb-b2be7f6ebe27",
      "name": "Format query results",
      "type": "n8n-nodes-base.set",
      "position": [
        1180,
        180
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "e9220e4e-8bdc-48ed-b29b-a2fe124b8b72",
      "name": "Prepare final output",
      "type": "n8n-nodes-base.set",
      "position": [
        2140,
        580
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "81a292e1-c5e9-40df-a181-66f767c60215",
      "name": "Combine query result and chat answer",
      "type": "n8n-nodes-base.merge",
      "position": [
        1880,
        580
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "4a35ebb4-37cb-4a7c-b005-70315c6f684c",
      "name": "List all tables in a database",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -740,
        -60
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "22da4137-af07-4c03-9c2d-6b8178571ff4",
      "name": "Convert data to Json",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -200,
        -60
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "0d7d1e90-224b-4159-8930-4470b140305d",
      "name": "Schema Extractor",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -560,
        -60
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "ddba033b-aca0-42a0-b553-3edf4d93cd1f",
      "name": "Final SQL result",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1000,
        180
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "3c2b1a0d-4a50-44b2-ada9-00d3b23b3c61",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        180
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "4ad38866-185e-4cd3-b0b0-b1e744d52204",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1900,
        420
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "744b6680-310b-4a89-a84c-dc59145fe73f",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        2120,
        180
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "196473ba-78c5-412c-8940-121a0e1f28d2",
      "name": "plot agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1700,
        180
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "9e03e081-0de2-4b8e-bcaa-adc0d2240272",
      "name": "deepseek-chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1700,
        380
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "376d0712-00c4-4132-a429-b36234e75316",
      "name": "Deepseek-chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        360
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "43d27038-22c0-41ec-b2b5-507c311b23f1",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c206c591-5826-4285-900a-c082587bfbaa",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "57bbe158-4ddc-4f46-b871-d22735e3f720",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        580
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "93ee6099-65dc-47bc-ba35-15f2e22b1412",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Extract SQL query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "plot agent": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "plot agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "Load the schema from the local file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Combine query result and chat answer",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Deepseek-chat": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "deepseek-chat": {
      "ai_languageModel": [
        [
          {
            "node": "plot agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Final SQL result": {
      "main": [
        [
          {
            "node": "Format query results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schema Extractor": {
      "main": [
        [
          {
            "node": "Add table name to output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract SQL query": {
      "main": [
        [
          {
            "node": "Check if query exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert data to Json": {
      "main": [
        [
          {
            "node": "Save file locally",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format query results": {
      "main": [
        [
          {
            "node": "Combine query result and chat answer",
            "type": "main",
            "index": 0
          },
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Check if query exists": {
      "main": [
        [
          {
            "node": "Combine query result and chat answer",
            "type": "main",
            "index": 1
          },
          {
            "node": "Final SQL result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract data from file": {
      "main": [
        [
          {
            "node": "Combine schema data and chat input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add table name to output": {
      "main": [
        [
          {
            "node": "Convert data to Json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "plot agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "List all tables in a database": {
      "main": [
        [
          {
            "node": "Schema Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \"Test workflow\"": {
      "main": [
        [
          {
            "node": "List all tables in a database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine schema data and chat input": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load the schema from the local file": {
      "main": [
        [
          {
            "node": "Extract data from file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine query result and chat answer": {
      "main": [
        [
          {
            "node": "Prepare final output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow enables users to interact with a PostgreSQL database using natural language. It translates text inputs into SQL queries, retrieves the corresponding data, and generates visualizations using QuickChart, facilitating seamless data analysis without manual query…

Source: https://n8n.io/workflows/3497/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow automates hospital emergency department triage by intelligently processing patient intake information through multiple AI-powered assessment stages. Designed for emergency departments, u

Chat Trigger, Agent, OpenAI Chat +5
AI & RAG

HDW Lead Geländewagen. Uses chatTrigger, lmChatOpenAi, memoryBufferWindow, outputParserStructured. Chat trigger; 92 nodes.

Chat Trigger, OpenAI Chat, Memory Buffer Window +5
AI & RAG

by Varritech Technologies

Chat Trigger, Agent, OpenAI Chat +8
AI & RAG

Who’s it for Creators who want to create faceless videos automatically, while keeping human oversight and quality control.

Read Write File, Agent, OpenAI Chat +7
AI & RAG

Who is this workflow for? This workflow is designed for SEO analysts, content creators, marketing agencies, and developers who need to index a website and then interact with its content as if it were

Agent, OpenAI Chat, Memory Buffer Window +10