⚒️ Visualize your SQL Agent queries with OpenAI and Quickchart.io

16,437 views · ⚒️ Engineering

Description

Overview

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

Notes

🔗 Nodes Used

HTTP Request, Execute Sub-workflow, Execute Workflow Trigger, AI Agent, OpenAI Chat Model, Simple Memory

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup