This workflow is a chat-based Business Data Analyst Chatbot built in n8n.
It allows users to ask business questions in plain English and receive clean, stakeholder-friendly insights based on data stored in one or more connected Google Sheets.
The workflow uses an AI Agent connected to:
This workflow is useful for experimenting with conversational business intelligence, spreadsheet analysis, AI agents, and tool-based automation.
Example questions users can ask:
This workflow is designed as a learning and demonstration project.
It is intentionally built to be flexible. The AI Agent is not hardcoded to one specific question or one specific dataset. Instead, the system prompt guides the agent to understand the user’s business question, decide what data is needed, select the most relevant Google Sheets tool, retrieve the data, and then perform the analysis.
A few important points:
This workflow does not include real API keys or credentials. You must configure your own credentials inside your private n8n environment.
The workflow follows this structure:
When chat message received
↓
AI Agent
↓
Google Sheets Tool(s)
↓
Edit Fields
↓
Chat Response
The workflow starts when the user sends a message through the n8n chat interface.
The Chat Trigger should use:
Response Mode: Using Response Nodes
This allows a later Chat Response node to send the final answer back to the user.
The AI Agent receives the user’s question and acts as the business analyst.
The agent:
The AI Agent should be connected to:
Each Google Sheets node is connected to the AI Agent as a tool.
Each tool represents one dataset. For example:
The AI Agent chooses the correct tool based on the user’s question and the tool descriptions.
Example tool description for an e-commerce dataset:
Use this tool to retrieve order-level e-commerce sales data, including customer, gender, payment method, product category, quantity, price, region, order status, and rating.
Example tool description for a marketing dataset:
Use this tool to retrieve marketing campaign performance data, including campaign name, channel, region, country, audience segment, device, spend, impressions, clicks, conversions, revenue, leads, and new customers.
Clear tool descriptions are important because they help the AI Agent decide which dataset to use.
The AI Agent usually returns its answer inside an output field.
The Edit Fields node maps that output into a clean response field.
Recommended configuration:
Field name: response
Field value: {{ $json.output.replace(/\\n/g, '\n') }}
Include Other Input Fields: OFF
This prevents the chat from displaying raw JSON or escaped newline characters.
The final Chat node sends the cleaned response back to the user.
Use this value in the message field:
{{ $json.response }}
Do not return:
{{ $json }}
Returning the full JSON object may cause the chat to show raw output such as:
[
{
"response": "..."
}
]
Download or copy the workflow template and import it into your n8n instance.
In n8n:
Open the When chat message received node and set:
Response Mode: Using Response Nodes
Open the OpenAI Chat Model node, or your preferred chat model node.
Create or select your credential.
You will need to provide your own API key inside n8n’s credential manager.
Do not place your API key directly inside the workflow JSON.
Open each Google Sheets Tool node and select your own Google Sheet document and sheet tab.
Recommended setup:
Resource: Sheet Within Document
Operation: Get Row(s) / Read Rows / Get Many Rows
Document: Your Google Sheet
Sheet: Your sheet tab
Use first row as headers: Enabled, if available
Return all rows: Enabled, if available
The exact options may vary depending on your n8n version.
For each Google Sheets tool, update the description to clearly explain what data the sheet contains.
Example:
Use this tool to retrieve marketing campaign performance data, including campaign name, channel, spend, impressions, clicks, conversions, revenue, region, and audience segment.
The better the tool description, the better the AI Agent can choose the correct dataset.
Try asking questions such as:
Which product category has the highest sales?
How are PayPal orders distributed by gender?
Which marketing channel has the highest ROAS?
Which campaign generated the most revenue?
Are mobile campaigns performing better than desktop campaigns?
To use this workflow, you need:
Recommended dataset format:
Example datasets:
You can customize this workflow by adding more datasets, changing the AI model, improving the prompt, or adjusting the final response format.
To add another dataset:
Example tool description:
Use this tool to retrieve customer support ticket data, including ticket ID, date, customer segment, issue type, priority, status, resolution time, satisfaction score, and assigned team.
The AI Agent system prompt should stay general and flexible.
Recommended system prompt:
You are a business data analyst.
You have access to one or more Google Sheets tools. Each tool may contain a different dataset.
For every user question:
1. Understand the business question and determine what type of data is needed.
2. Select the most relevant Google Sheets tool or tools based on the user’s question and the tool descriptions.
3. Retrieve the data before answering.
4. Analyze only the retrieved spreadsheet data.
5. Dynamically identify the relevant columns, metrics, filters, and groupings.
6. Perform calculations such as totals, averages, counts, percentages, rankings, comparisons, trends, correlations, and summaries where relevant.
7. If multiple datasets are needed, combine insights logically using matching columns if available.
8. If the user question is reasonably answerable from the available data, make a reasonable interpretation and proceed.
9. Only ask a clarification question when the analysis cannot be performed without more information.
10. If data is missing or insufficient, clearly explain what is missing.
Do not invent data.
Do not answer from memory.
Do not assume a fixed sheet structure.
Do not mention workflow or tool details unless the user asks.
Return a clear business-friendly answer in clean Markdown.
Use top-down communication: start with the key answer first, then supporting metrics, then insights or recommendations.
Do not return JSON.
Do not end with a follow-up question unless the user explicitly asks for one.
You can adjust the final answer style in the prompt.
For example, you can ask the AI Agent to return:
Example instruction:
Return the answer with a short headline, key metric summary, supporting table, and one recommendation.
You can replace the OpenAI Chat Model node with another compatible chat model node supported by n8n.
Make sure the model supports tool calling if you want the AI Agent to use Google Sheets tools dynamically.
Before sharing this workflow publicly, replace private values with placeholders.
Do not publish:
Use placeholders such as:
YOUR_OPENAI_CREDENTIAL_ID
YOUR_GOOGLE_SHEETS_CREDENTIAL_ID
YOUR_GOOGLE_SHEET_ID
YOUR_GOOGLE_SHEET_URL
YOUR_WEBHOOK_ID
YOUR_N8N_INSTANCE_ID
If you accidentally publish a secret, revoke or rotate it immediately. Deleting the file from GitHub may not be enough because secrets can remain in Git history.
User question:
How does the distribution of orders look between men and women using PayPal?
Example response:
## PayPal orders are more common among women
Women placed 19 PayPal orders, compared with 6 PayPal orders from men.
| Gender | PayPal Orders | Share of PayPal Orders |
|---|---:|---:|
| Women | 19 | 76% |
| Men | 6 | 24% |
**Key insight:** Women account for about three out of every four PayPal orders in this dataset.
**Recommendation:** Review PayPal usage by product category and region to understand where this behavior is strongest.
Use:
{{ $json.response }}
Do not use:
{{ $json }}
Set the Chat Trigger response mode to:
Using Response Nodes
Do not use a “Send and Wait for Response” operation for the final answer.
Use a normal response operation so the workflow sends the final answer and ends.
Check that:
This workflow is provided as a learning and demonstration template.
You are responsible for configuring your own n8n credentials, API keys, Google Sheets access, data permissions, and security settings.
The workflow does not include real API keys or credentials. Any placeholders in the workflow must be replaced with your own values inside your private n8n environment.
Do not use this workflow with sensitive, confidential, regulated, or personally identifiable data unless your n8n instance, AI provider, and data handling process meet your organization’s security and compliance requirements.