{
  "name": "Visualize your SQL Agent queries with OpenAI and Quickchart.io",
  "nodes": [
    {
      "id": "50695e7f-3334-4124-a46e-1b3819412e26",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1260,
        560
      ]
    },
    {
      "id": "2f07481d-3ca4-48ab-a8ff-59e9ab5c6062",
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        2360,
        280
      ]
    },
    {
      "id": "49120164-4ffc-4fe0-8ee3-4ae13bda6c8d",
      "name": "Execute \"Generate a chart\" tool",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        1320,
        1140
      ]
    },
    {
      "id": "0fc6eaf9-8521-44ec-987e-73644d0cba79",
      "name": "OpenAI - Generate Chart definition with Structured Output",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1620,
        1140
      ]
    },
    {
      "id": "8016a925-7b31-4a49-b5e1-56cf9b5fa7b3",
      "name": "Set response",
      "type": "n8n-nodes-base.set",
      "position": [
        1860,
        1140
      ]
    },
    {
      "id": "9a2b8eca-5303-4eb0-8115-b0d81bfd1d7c",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        880,
        380
      ]
    },
    {
      "id": "2a02c5ee-11e1-4559-bbfb-ea483e914e52",
      "name": "Set Text output",
      "type": "n8n-nodes-base.set",
      "position": [
        2200,
        480
      ]
    },
    {
      "id": "3b0f455a-ab1d-4dcd-ae97-708218c6c4b0",
      "name": "Set Text + Chart output",
      "type": "n8n-nodes-base.set",
      "position": [
        2540,
        280
      ]
    },
    {
      "id": "29e2381a-7650-4e9a-a97f-26c7550ff7ba",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1400,
        380
      ]
    },
    {
      "id": "c5fdff53-29fa-474e-abcc-34fa4009250c",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1560,
        540
      ]
    },
    {
      "id": "4e630901-6c6c-4e86-af66-c6dfb9a92138",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        60
      ],
      "parameters": {
        "width": 681,
        "height": 945,
        "content": "### Overview  \n- This workflow aims to provide data visualization capabilities to a native SQL Agent.  \n- Together, they can help foster data analysis and data visualization within a team.  \n- It uses"
      }
    },
    {
      "id": "36d7b17f-c7df-4a0a-8781-626dc1edddee",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        800
      ],
      "parameters": {
        "width": 769,
        "height": 523,
        "content": "## Generate a Quickchart definition \n[Original template](https://n8n.io/workflows/2400-ai-agent-with-charts-capabilities-using-openai-structured-output-and-quickchart/)\n\n**HTTP Request node**\n- Send t"
      }
    },
    {
      "id": "9ccea33b-c5d9-422e-a5b9-11efbc05ab1a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        60
      ],
      "parameters": {
        "width": 888,
        "height": 646,
        "content": "### Information Extractor \n- This Information Extractor is added to extract the user's question\n- In some cases, if the question contains a visualization aspect, the SQL Agent may not responding accur"
      }
    },
    {
      "id": "d8bf0767-faf0-4030-b325-08315188adcb",
      "name": "OpenAI Chat Model Classifier",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1900,
        540
      ]
    },
    {
      "id": "4bcd676f-44f3-4242-a5fd-7cf2098a3a64",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        60
      ],
      "parameters": {
        "width": 948,
        "height": 646,
        "content": "### Respond with a text only or also include a chart \n- The text classifier determines if the response from the SQL Agent would benefit from a chart\n- If it does, then it executes the subworkflow to d"
      }
    },
    {
      "id": "256cb28b-0d83-4f6d-bb11-33745c9efa4a",
      "name": "Text Classifier - Chart required?",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        1800,
        380
      ]
    },
    {
      "id": "6df60db5-19c0-4585-a229-b56f4b9a2b29",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        1020
      ],
      "parameters": {
        "width": 680,
        "height": 720,
        "content": "## Demo\n![Demo SQL Agent](https://media.licdn.com/dms/image/v2/D4E22AQERT4FEXEUncw/feedshare-shrink_800/feedshare-shrink_800/0/1731433289953?e=1741824000&v=beta&t=e6xUqjcsSq5U_NELeD-nn1mFROGYZLazkYC0e"
      }
    },
    {
      "id": "a843845d-e010-4a09-ab50-e169beb67811",
      "name": "User question + Agent initial response",
      "type": "n8n-nodes-base.set",
      "position": [
        2200,
        280
      ]
    },
    {
      "id": "12c9dc38-c0fe-4f4c-a101-ec1ff7ea9048",
      "name": "Information Extractor - User question",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        1060,
        380
      ]
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Text Classifier - Chart required?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "Set Text + Chart output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Information Extractor - User question",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Information Extractor - User question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model Classifier": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier - Chart required?",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Execute \"Generate a chart\" tool": {
      "main": [
        [
          {
            "node": "OpenAI - Generate Chart definition with Structured Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier - Chart required?": {
      "main": [
        [
          {
            "node": "User question + Agent initial response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Text output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor - User question": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "User question + Agent initial response": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Generate Chart definition with Structured Output": {
      "main": [
        [
          {
            "node": "Set response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}