Skip to main content

Visualize your SQL Agent queries with OpenAI and Quickchart.io

Workflow preview

Workflow preview
100%
Visualize your SQL Agent queries with OpenAI and Quickchart.io preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow aims to provide data visualization capabilities to a native SQL Agent. Together, they can help foster data analysis and data visualization within a team. It uses the native SQL Agent ...

Best for

  • Engineering automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.executeworkflow, n8n-nodes-base.executeworkflowtrigger, n8n-nodes-base.httprequest, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.memorybufferwindow

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Agent Studio.

Original n8n.io source

1.1 Workflow description

Title
Visualize your SQL Agent queries with OpenAI and Quickchart.io
Workflow name
Visualize your SQL Agent queries with OpenAI and Quickchart.io

Overview

  • This workflow aims to provide data visualization capabilities to a native SQL Agent.
  • Together, they can help foster data analysis and data visualization within a team.
  • It uses the native SQL Agent that works well and adds visualization capabilities thanks to OpenAI’s Structured Output and Quickchart.io.

How it works

  1. Information Extraction:

    • The Information Extractor identifies and extracts the user's question.
    • If the question includes a visualization aspect, the SQL Agent alone may not respond accurately.
  2. SQL Querying:

    • It leverages a regular SQL Agent: it connects to a database, queries it, and translates the response into a human-readable format.
  3. Chart Decision:

    • The Text Classifier determines whether the user would benefit from a chart to support the SQL Agent's response.
  4. Chart Generation:

    • If a chart is needed, the sub-workflow dynamically generates a chart and appends it to the SQL Agent’s response.
    • If not, the SQL Agent’s response is output as is.
  5. Calling OpenAI for Chart Definition:

    • The sub-workflow calls OpenAI via the HTTP Request node to retrieve a chart definition.
  6. Building and Returning the Chart:

    • In the "Set Response" node, the chart definition is appended to a Quickchart.io URL, generating the final chart image.
    • The AI Agent returns the response along with the chart.

How to use it

  • Use an existing database or create a new one.
  • For example, I've used this Kaggle dataset and uploaded it to a Supabase DB.
  • Add the PostgreSQL or MySQL credentials.
  • Alternatively, you can use SQLite binary files (check this template).
  • Activate the workflow.
  • Start chatting with the AI SQL Agent.
  • If the Text Classifier determines a chart would be useful, it will generate one in addition to the SQL Agent's response.

Notes

  • The full Quickchart.io specifications have not been fully integrated, so there may be some glitches (e.g., radar graphs may not display properly due to size limitations).

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 2 - Execute Workflow

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.1

Block 3 - Execute "Generate a chart" tool

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1

Block 4 - OpenAI - Generate Chart definition with Structured Output

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 5 - Set response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 7 - Set Text output

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Set Text + Chart output

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 10 - Window Buffer Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.2

Block 11 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - OpenAI Chat Model Classifier

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 15 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Text Classifier - Chart required?

Type / Role
@n8n/n8n-nodes-langchain.textClassifier - textClassifier
Config choices
Version 1

Block 17 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - User question + Agent initial response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Information Extractor - User question

Type / Role
@n8n/n8n-nodes-langchain.informationExtractor - informationExtractor
Config choices
Version 1

3. Summary Table

Workflow Visualize your SQL Agent queries with OpenAI and Quickchart.io
Complexity advanced
Nodes 19
Categories Engineering, AI Chatbot
Author Agent Studio
Published 20 Nov 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2559/2559.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Visualize your SQL Agent queries with OpenAI and Quickchart.io do?

This workflow aims to provide data visualization capabilities to a native SQL Agent. Together, they can help foster data analysis and data visualization within a team. It uses the native SQL Agent ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI Chatbot use case.