This n8n workflow enables an AI-powered chat agent to generate and embed dynamic charts based on user queries. The workflow integrates OpenAI’s GPT-4 model with chart creation capabilities, allowing the AI to produce visual data representations seamlessly within a conversation. It leverages structured output from OpenAI to define charts in JSON format aligned with Chart.js and quickchart.io specifications.
Here’s how it works: When a user sends a message, the workflow triggers and passes the query to the AI agent. If the user requests a chart, the agent calls a sub-workflow that sends the query to OpenAI’s API, requesting a chart definition with precise configuration parameters. The OpenAI node uses a custom prompt to generate a valid Chart.js configuration, focusing on clarity, color differentiation, and proper scaling.
Once the chart definition is received, it is processed by a Set node to generate a Quickchart URL, embedding the JSON configuration as a parameter. The URL points to an image of the chart hosted via Quickchart.io, which is then displayed within the conversation. This setup is especially useful for data analysts, business intelligence, or educational scenarios where visual data storytelling enhances understanding.
The workflow demonstrates an innovative approach to combining AI language models with visual data tools, enabling smarter, more interactive chatbot experiences with real-time chart generation.
Reviews
There are no reviews yet.