Create AI-Driven Chart Visualizations with n8n and OpenAI

Discover how to empower your AI Agent with real-time chart generation using n8n and OpenAI’s Structured Output. This workflow transforms text queries into detailed Quickchart.io visualizations, streamlining data presentation in chat interfaces.
agent
lmChatOpenAi
memoryBufferWindow
+6
Workflow Identifier: 2157
NODES in Use: agent, lmChatOpenAi, memoryBufferWindow, toolWorkflow, executeWorkflowTrigger, httpRequest, set, chatTrigger, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow listens for chat messages in n8n and uses AI to create charts from text requests automatically.
It solves the problem of spending lots of time making charts manually during chats or meetings.
You get a chat where the AI agent can show charts directly in the conversation by building Chart.js JSON and using Quickchart.io to display images.


Who should use this workflow

Anyone who talks with non-technical people and needs quick charts from data.
People who want to save time by not switching between chat and chart tools.
Users needing live data visuals during conversations without delays or errors.


Tools and services used

  • n8n Workflow Automation: Runs the automation steps.
  • OpenAI API (GPT-4o, GPT-4o-mini models): Understands chat and generates Chart.js JSON.
  • Quickchart.io: Converts Chart.js JSON into chart images.
  • LangChain Nodes in n8n: Manages AI agent, memory, and workflow tools.

Inputs, processing steps, and outputs

Inputs

  • User chat messages asking for charts, for example “Show me sales trend”.
  • OpenAI API key added in n8n credentials.
  • No special account needed for Quickchart.io.

Processing steps

  • Webhook node waits for chat messages.
  • AI Agent node reads the chat and decides if a chart is requested.
  • OpenAI Chat Model node processes natural language to understand intent.
  • Window Buffer Memory node remembers recent chat to keep context.
  • Generate a chart tool workflow is called when chart needed.
  • Execute “Generate a chart” tool node triggers the chart sub-workflow.
  • OpenAI – Generate Chart definition with Structured Output node makes an HTTP POST request to OpenAI to get Chart.js JSON matching user request.
  • Set response node builds a Quickchart.io URL encoding the JSON to create a chart image.
  • The AI agent replies in chat showing the chart image inline.

Outputs

  • Message replies in chat including dynamic chart images.
  • Quickchart URLs that generate correct charts based on user queries.

Beginner step-by-step: How to build this in n8n

Import and Prepare

  1. Download the workflow file using the “Download” button on this page.
  2. Open n8n editor and use “Import from File” to add the workflow.
  3. Check that all node names appear as expected.

Configure Credentials and Settings

  1. Set OpenAI API Key in credential manager.
  2. Review the OpenAI Chat Model and HTTP Request nodes to confirm model names.
  3. If needed, update IDs or channels if the workflow uses them (usually none here).
  4. Ensure the webhook in the Webhook node is active for chat input.

Test and Activate

  1. Send a test chat message that asks for a chart (example: “Show me sales over time”).
  2. Wait for the AI agent to reply with a chart image.
  3. If output is as expected, activate the workflow for regular use.

If running on your own server, consider self-host n8n options for stable production.


Customization ideas

  • Change chart size by editing Quickchart URL parameters.
  • Add chart titles by modifying the system prompt in the OpenAI HTTP Request node.
  • Support more chart types by extending the Chart.js JSON schema.
  • Adjust memory size to keep longer or shorter chat history in Window Buffer Memory node.
  • Switch to newer OpenAI models in the Chat Model node for improved AI understanding.

Edge cases and common errors

  • Error “Invalid API key” usually means OpenAI credential is wrong or missing.
  • No chart generation when AI does not recognize chart requests.
  • Malformed charts can happen if OpenAI outputs incorrect JSON or URL is not encoded.
  • Memory node disconnected causes AI to forget conversation context abruptly.

Summary of results

✓ Chat messages get quick dynamic charts in response.
✓ Saves hours of manual chart making.
✓ Keeps conversation natural and visual.
✓ Supports many common chart types.
✓ Works with free Quickchart service.
✓ Easy to import and start using in n8n.

Frequently Asked Questions

The chart generation is triggered when the AI Agent detects a request for a chart in the incoming chat message.
The workflow uses GPT-4o-mini and GPT-4o models from OpenAI to generate the chat responses and Chart.js JSON definitions.
Quickchart.io converts the Chart.js JSON definitions into chart images by encoding the JSON in a URL that the AI Agent sends in chat.
The Window Buffer Memory node stores recent chat history to help the AI Agent maintain context during the conversation.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free