Flight Data Analytics Bot using Telegram and QuickChart - n8n Workflow

Deploy a powerful data analytics n8n workflow that uses a Telegram bot to instantly visualize CSV flight data into professional Bar, Pie, Doughnut, and Line charts using the QuickChart API and custom n8n code.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted text:
Data analysts or business users needing rapid, on-demand visualization without traditional BI tools.
Developers looking for advanced n8n templates that showcase data processing and external API integration.
Users aiming to deploy complex, data-driven Telegram bots using n8n node automation.
Anyone interested in using custom code scripting within an n8n workflow for dynamic chart generation.

Overview

This comprehensive n8n workflow transforms raw, static flight data stored in a CSV file into dynamic, visually rich charts delivered directly through Telegram. The primary goal is to provide instant data insights, making complex analytics accessible through a simple conversational interface. The automation begins with a Telegram n8n trigger and routes user requests to specific analysis paths. By utilizing custom JavaScript inside the Code n8n node, the workflow calculates essential metrics (like top airline counts or average prices) and translates them into Chart.js configurations. These configurations are then sent to the QuickChart API, which returns a professional PNG image. This setup highlights the immense potential of n8n for combining messaging platforms, custom logic, and visualization APIs into seamless, high-value data tools. This particular n8n workflow serves as an excellent example for creating powerful, user-facing applications.

How it Works

Markdown-formatted text:


  1. Initiation: The process starts when a user sends a message or presses a button. The Telegram n8n trigger captures this interaction.

  2. Command Check: The If n8n node checks if the user sent the /start command. If so, a friendly menu with four chart options (using a reply keyboard) is delivered via a Telegram n8n node.

  3. Data Loading: If the message is a chart selection, the n8n workflow proceeds to the Read CSV File n8n node, loading the raw data from the local /data/flights.csv path.

  4. Parsing: The Extract from File n8n node converts the raw CSV binary data into structured JSON objects, preparing the data for computation.

  5. Routing: The crucial Switch n8n node evaluates the user's selected chart title (e.g., "1️⃣ Top Airlines (Bar Chart)") and intelligently routes the flow to the correct processing branch.

  6. Visualization Logic: One of the four dedicated Code n8n nodes executes custom JavaScript logic. This script performs data aggregation (e.g., counting flight durations, calculating price averages) and generates a specialized Chart.js configuration, producing a QuickChart URL as output.

  7. Image Fetching: The subsequent HTTP Request n8n node uses the generated QuickChart URL to fetch the rendered PNG image as binary data.

  8. Delivery: Finally, a Telegram n8n node sends the binary chart image directly back to the user's chat, along with a descriptive caption summarizing key findings, concluding the cycle of this sophisticated n8n workflow.

Installation Guide

Markdown-formatted text:


  1. Import the n8n workflow: Copy the provided JSON code and import it directly into your n8n instance using the 'New' > 'Import from JSON' function.

  2. Telegram Bot Setup: You must obtain a Telegram Bot Token from BotFather. Create a new Telegram credential in n8n for the Telegram nodes (Trigger and all Send nodes).

  3. File Setup: This n8n workflow relies on a local file at /data/flights.csv. Ensure you create the necessary /data directory in your n8n host environment (especially if running via Docker) and place your flight data CSV file there.

  4. QuickChart API: No specific credential setup is required for the QuickChart API as it uses public URLs. The service is called via standard HTTP Request n8n nodes.

  5. Activation: Once credentials are set and the CSV file is in place, activate the Telegram Trigger n8n node to start listening for commands. Send /start to your Telegram bot to initialize the n8n trigger and test the n8n workflow.

Node Details

Markdown-formatted text:
Telegram Trigger: Function: The core n8n trigger that initiates the automation upon receiving a user message. Key Configuration: Configured to listen for message and callback_query updates.
Read CSV File / Extract from File: Function: These two nodes work together to locate the flight data (/data/flights.csv), load its raw content, and transform it into a collection of JSON objects for immediate processing within the n8n workflow.
Check Start (If node): Function: Provides crucial flow control by checking if the incoming Telegram message text is exactly /start, routing users to the welcome menu or the data processing pipeline.
Switch: Function: A central control flow n8n node that directs execution to one of the four chart generation branches based on the user's explicit button selection from Telegram.
Process Data & Create X Chart (Code node): Function: The heart of the analysis. Each of the four Code n8n node instances contains custom JavaScript to perform distinct aggregations (e.g., calculating top 10 airlines, grouping prices) and serialize the results into a QuickChart API URL using Chart.js JSON syntax.
HTTP Request (Fetch X Chart Image): Function: Fetches the rendered PNG image. Key Configuration: The URL is dynamically derived from the output of the preceding Code n8n node ({{ $json.quickChartUrl }}), fetching the binary image data.


  • Telegram (Send X Chart to Telegram): Function: The final action n8n node that sends the fetched binary photo back to the user's chat ID, ensuring dynamic and personalized responses.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

Smart Connection Analysis from Open Data, Globally at Scale

Featured*