Interactive Snowflake Data Explorer and GPT-4o Chat Interface - n8n Workflow

Build an advanced n8n workflow to chat conversationally with your Snowflake data warehouse using GPT-4o. Automate SQL generation, execute queries, and generate interactive HTML dashboards using this n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data Analysts and Scientists needing a quick, conversational way to query large Snowflake tables.
Automation Specialists looking for complex n8n templates integrating LangChain agents with databases.
Business Users who require interactive data reports without writing complex SQL.
Developers implementing robust RAG (Retrieval-Augmented Generation) patterns within n8n.

Overview

This sophisticated n8n workflow solves the challenge of conversational data access in Snowflake. Instead of manually writing and executing SQL, users can simply ask questions in natural language. The core value lies in its intelligent routing: a GPT-4o-powered AI agent dynamically generates the precise SQL query by leveraging tools that inspect the Snowflake schema. For small results (under 100 rows), the data is returned instantly. Critically, if the result set is large, the n8n workflow automatically generates an interactive HTML dashboard, complete with Chart.js visualization, pagination, and filtering, providing an excellent, user-friendly experience for handling big data results. This powerful n8n solution significantly speeds up data exploration.

How it Works

The entire process is driven by two interconnected n8n workflows: the Agent Flow and the Report Flow.


  1. AI Conversation Trigger: The Agent Flow begins with the When chat message received n8n trigger when a user sends a query.

  2. AI Agent Processing: The AI Agent1 uses OpenAI Chat Model1 (GPT-4o-mini) and Simple Memory (for conversation context) to analyze the user's request.

  3. Schema Retrieval (RAG): The agent consults the DB Schema1 and Get table definition Snowflake tools to gather necessary database structure information (this is a key part of the retrieval mechanism).

  4. SQL Generation & Execution: The agent generates an SQL query and calls the Retrieve Data tool, which executes the secondary Report Flow using the Execute Workflow Trigger n8n node.

  5. Database Query: The Report Flow uses the Execute SQL n8n node to run the generated SQL against Snowflake.

  6. Flow Control Logic: The Aggregate Data and If Count>100 n8n node checks the number of rows returned.

  7. Response Handling: If the count is low, the Return Data node sends the result back to the AI agent for final text summarization. If the count exceeds 100, the Link to Report node generates a markdown hyperlink to a dedicated public Webhook that holds the data for visualization.

  8. Interactive Report Generation: If the user clicks the link, the public Webhook n8n trigger fires. It re-runs the SQL via Snowflake1 and passes the full dataset to the Set HTML n8n node, which renders the dynamic, interactive HTML report with data tables and Chart.js graphs. The report is finally displayed using the Respond to Webhook n8n node.

Installation Guide

To deploy this advanced n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON and import it into your n8n instance.

  2. Set up Snowflake Credentials: Configure the required Snowflake credentials (named 'Snowflake account' in the workflow) to connect to your database, providing the necessary host, account, warehouse, and security details.

  3. Set up OpenAI Credentials: Ensure your OpenAI API key is configured and linked to the OpenAI Chat Model1 n8n node.

  4. Configure Tool Workflows: The Retrieve Data n8n node calls a nested workflow. Identify the Workflow ID of the Report Flow (the part starting with 'When Executed by Another Workflow') and update the Retrieve Data tool's configuration to reference that ID.

  5. Customize Schema Information: In the DB Schema1 and Get table definition n8n nodes, replace the placeholder schema name (TPCH_SF1) with your actual Snowflake schema name.

  6. Update Webhook URL: The Link to Report n8n node uses a hardcoded URL (https://n8n.lowcoding.dev/webhook/...). Replace this with the public URL of your n8n instance followed by the path of the secondary Webhook n8n trigger (e.g., https://your.n8n.url/webhook/87893585-d157-468d-a9af-7238784e814c).

  7. Activate: Ensure both parts of this powerful n8n workflow are active and test the chat endpoint.

Node Details

When chat message received (n8n trigger): The starting point of the AI conversation. It captures user input and maintains the session ID for memory.
AI Agent1 (Langchain Agent): The central processing unit of this n8n workflow. It orchestrates the use of the LLM and various tools to fulfill user requests, acting as the 'Snowflake SQL assistant.'
OpenAI Chat Model1: Utilizes gpt-4o-mini to provide state-of-the-art query understanding and SQL generation capabilities within the n8n environment.
Retrieve Data (Tool Workflow): An essential n8n node for structuring complex automations. It calls the sub-workflow dedicated to SQL execution, passing the AI-generated query as an input parameter.
DB Schema1 & Get table definition (Snowflake Tool nodes): These tools dynamically inform the AI Agent about the available tables and their column definitions, crucial for generating syntactically correct and meaningful SQL queries.
Execute SQL (Snowflake node): Executes the SQL query received from the AI agent against the Snowflake database.
If Count>100 (If node): A critical flow control n8n node that branches the automation path based on the size of the result set.
Link to Report (Set node): Creates the dynamic markdown link to the visualization endpoint when large data is detected, demonstrating smart data handling within the n8n workflow.
Webhook (n8n trigger): A standalone public n8n trigger used specifically to initiate the visual reporting phase, receiving the SQL query via URL parameters.
Set HTML (Set node): Contains a massive payload of custom HTML, CSS, and JavaScript (including Chart.js) to render a fully interactive, filterable, and graphable dashboard from the returned Snowflake data. This highly customized n8n node generates the user interface.

Related n8n Workflows

Free

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

I am a business analyst with a development background, dedicated to helping small businesses and entrepreneurs leverage cloud services for increased efficiency. My expertise lies in automating manual workflows, integrating data from multiple cloud service providers, creating insightful dashboards, and building custom CRM systems. https://www.linkedin.com/in/marklowcoding/

Featured*