n8n

How to Generate OpenAI Chat Charts for Visual Reports?

Give your chat users instant charts on request. A built in agent turns plain text questions into clean images you can drop into marketing updates and meeting notes. Great for teams that need quick visuals without opening a dashboard.

A chat message starts the flow and routes into an AI agent. The agent uses an OpenAI chat model with short term memory to keep context. When a chart is needed, it triggers a tool with a simple input called query. That tool runs a sub flow that sends a structured request to OpenAI to create a Chart.js style JSON. A Set node then turns that JSON into a quickchart link with width 200 and sends the URL back. The agent replies in the chat with the image so the chart appears inline.

You need an OpenAI API key and n8n access. Quickchart links work without an account. Teams often cut ad hoc report prep from about 30 minutes to about 1 minute per request. Common uses include campaign snapshots, weekly sales summaries, and quick status visuals for standups. Start by importing the template, add your OpenAI key, test with a simple prompt like bar chart of top 5 movies, and adjust width if your chat UI needs a different size.

What are the key features?

  • Chat message trigger routes new messages into the agent using a webhook ID.
  • OpenAI chat model with window buffer memory keeps recent context in the conversation.
  • Tool with a defined input schema accepts a single field called query to describe the chart.
  • Execute workflow trigger runs the chart generator as a sub flow for clean separation.
  • HTTP Request node asks OpenAI for a structured Chart.js style JSON definition.
  • Set node encodes the JSON into a quickchart URL with width 200 for clear display.
  • Agent replies with a markdown image so the chart shows inline in the chat.

What are the benefits?

  • Reduce manual chart creation from 30 minutes to 1 minute
  • Automate up to 80 percent of ad hoc chart requests
  • Improve consistency by using one chart spec across chats
  • Support multiple chat users without extra work
  • Connect OpenAI output to quickchart links with no extra apps

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI and QuickChart. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, create a new OpenAI API Key credential. Copy your API key from your OpenAI account and paste it into the credential form, then save.
  4. Open the node named OpenAI Generate Chart definition with Structured Output. In Credential to connect with, select your OpenAI credential. Confirm the request uses model gpt 4o 2024 08 06 and Content Type application json.
  5. Open the tool node named generate a chart. Confirm the input schema has one field called query of type string. Keep the tool name as generate a chart so the agent can find it.
  6. Open the Set response node. Verify the expression builds a quickchart link and uses encodeURIComponent on the OpenAI JSON. Keep width set to 200 or adjust for your chat UI.
  7. Open the AI Agent node. Make sure the language model, memory, and the generate a chart tool are all connected. Keep the system message that allows image display.
  8. Activate the workflow and open the chat interface. Send a prompt like line chart of weekly signups for 8 weeks. You should see an image URL and the chart inline.
  9. If no image appears, check the HTTP Request node output for a valid JSON. Make sure the path choices[0].message.content is present and the Set node encodes it correctly.
  10. If charts look cut off, increase the width value in the quickchart URL. If the agent does not call the tool, recheck the tool name and the input schema.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

QuickChart

Sign up

Community (Free): $0 / mo, 1,000 QR codes / mo; 60/min rate limit; unlimited scans; never expire

Credits:
Baptiste

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.