Langflow 1.7 just released
Back to templates

Interactive Data Dashboards

Transform natural language questions into SQL queries and custom charts with this intelligent database visualization system. Built in Langflow's visual interface, it uses a two-stage agent architecture to automatically query databases and generate appropriate visual representations from plain English questions.

Share

If the flow preview doesn't load, you can open it in a new tab.

This Langflow flow creates an intelligent database query and visualization system that transforms natural language questions into SQL queries and generates custom charts. The system allows users to ask questions about their database in plain English and automatically produces both data results and appropriate visual representations. Langflow's visual interface makes building this sophisticated data pipeline fast and requires minimal coding.

How it works

This Langflow flow creates an intelligent database query and visualization system that transforms natural language questions into SQL queries and generates custom charts. The flow operates through a two-stage agent architecture that handles both data retrieval and visualization generation. Users can ask questions about their database in plain English, and the system will automatically query the database and create appropriate visual representations of the results.

The first stage uses a SQL specialist agent that receives user questions and database schema information. This agent analyzes the schema to understand the database structure and generates appropriate SQL queries to answer the user's question. The agent has access to a SQL database tool that can execute queries against the configured database. The results are returned in JSON format for further processing by the visualization stage.

The second stage employs a data visualization agent that takes the JSON results from the database query and generates Python code to create charts using Matplotlib. This agent evaluates the data structure and user requirements to determine the most appropriate visualization type. The generated Python code creates charts in base64 format, which are then formatted and displayed to the user. The system requires proper configuration of the database URL, schema definition, and Matplotlib installation to function correctly.

The flow begins with a chat input component that captures user questions in natural language. Prompt templates shape the instructions for both agents, ensuring they understand their specific roles in the pipeline. The system uses structured output formatting to maintain consistent data flow between stages and can be tested thoroughly in Langflow's playground environment.

Example use cases

  • Sales teams can ask "show me revenue trends by product category this quarter" and receive both tabular data and line charts automatically.

  • Marketing analysts can query "compare conversion rates across channels last month" and get bar charts with the underlying metrics.

  • Operations managers can request "display inventory levels by warehouse location" and see both the data and appropriate visualizations.

  • Finance teams can ask "what are our top expenses by department" and receive pie charts with supporting data tables.

  • Customer service can query "show ticket volume trends by priority level" and get time series charts with the raw numbers.

The flow can be extended significantly using other Langflow components. You could add dataframe operations for advanced data transformations, integrate API requests to pull data from multiple sources, or implement smart routing to direct different question types to specialized processing paths. The system could also incorporate RAG capabilities to answer questions about unstructured documents alongside database queries, or use webhook triggers to automatically generate reports based on external events.

What you'll do

  • 1.

    Run the workflow to process your data

  • 2.

    See how data flows through each node

  • 3.

    Review and validate the results

What you'll learn

How to build AI workflows with Langflow

How to process and analyze data

How to integrate with external services

Why it matters

Transform natural language questions into SQL queries and custom charts with this intelligent database visualization system. Built in Langflow's visual interface, it uses a two-stage agent architecture to automatically query databases and generate appropriate visual representations from plain English questions.

Create your first flow

Join thousands of developers accelerating their AI workflows. Start your first Langflow project now.

gradiant