Build a Google Sheets Business Data Analyst Chatbot with n8n AI Agent
Type a natural-language business question → AI Agent auto-selects Google Sheets dataset → analyzes and returns structured insights
- Who
- Ops or data team members who want to quickly set up a conversational business-data analysis bot in n8n
- You get
- Users ask questions in plain language; the bot automatically pulls data from Google Sheets, computes metrics, and replies with Markdown tables, insights, and recommendations
- You need
- n8n · google-sheets
Constraints
Prerequisites: an n8n instance; an OpenAI API credential; a Google Sheets OAuth2 credential; at least one structured Google Sheet with clear column headers in the first row. This template is a learning/demo project and does not include real API keys.
What they did
Author missylearnsai built an n8n template featuring an AI Agent chatbot. Users ask natural-language business questions via the n8n chat interface; the AI Agent, backed by an OpenAI model and conversation memory, automatically selects the appropriate Google Sheets Tool node, retrieves data, formats the result through Edit Fields, and returns the answer via Chat Response. The template includes two sample datasets (e-commerce orders and marketing campaigns) and provides a complete system prompt, tool description examples, and troubleshooting notes.
How it went
The author reports the template supports conversational business intelligence experiments, including counts, totals, averages, percentages, rankings, comparisons, trends, and correlations. An example question, "How does the distribution of orders look between men and women using PayPal?", produced a Markdown answer with a table, key insight, and recommendation. (author_report)
Worth knowing
1. This is a learning/demo template; real API keys and credentials must be configured separately. 2. Default model is gpt-4.1-mini; gpt-4.1 or gpt-4 can be selected in the n8n node parameters. Tool-calling support is required. 3. The quality of Google Sheets tool descriptions directly affects the AI Agent's tool-selection accuracy; rewrite them to match your actual column names. 4. If the chat shows raw JSON, verify that Chat Response uses {{ $json.response }} (not {{ $json }}) and that Edit Fields has Include Other Input Fields turned OFF. 5. Before sharing the workflow publicly, replace all YOUR_* placeholders to avoid leaking credential IDs, sheet IDs, or webhook IDs. 6. This site has not tested the template; reproduction=not_tested. Google Sheets node parameter options may vary slightly across n8n versions.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- OpenAI Chat Model node: connect OpenAI API credentials.
- E-commerce Orders & Customer Analysis node: connect Google Sheets OAuth2 credentials.
- Marketing Campaign Performance Analysis node: connect Google Sheets OAuth2 credentials.
Configuration to replace
- Source template is n8n public workflow #15424 (~17 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-25
Steps
Configure the Chat Trigger
Open the "When chat message received" node in n8n and set Response Mode to "Using Response Nodes". This allows a later Chat Response node to send the final answer back to the user.
Configure the AI Agent and System Prompt
Add an AI Agent node, connect an OpenAI Chat Model (default gpt-4.1-mini, alternatives gpt-4.1 / gpt-4) and Simple Memory (optional but recommended for conversational context). Paste the following system prompt into the AI Agent's System Message field. The prompt instructs the agent to understand the question, select the right Google Sheets tool, retrieve data before answering, and forbids inventing data or assuming a fixed sheet structure.
Execution prompt · Source text。AI Agent node System Message field
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 right dataset, column, or relationship is unclear, ask a short clarification question. 9. If the data is missing or insufficient, clearly explain what is missing. Do not invent data. Do not answer from memory. Do not assume a specific sheet structure. Do not mention workflow or tool details unless the user asks. Return a clear business-friendly answer in a top-down communication fashion. Top-down means that you would start with your key point first, then provide supporting arguments. Return the answer as a clean Markdown for a chat user with numbers, insights, and recommendations where useful. Do not return JSON. Do not include escaped newline characters. Do not end with a follow-up question unless the user explicitly asks for one.
Configure Google Sheets Tool Nodes
Add one Google Sheets Tool node per dataset and connect each to the AI Agent as an AI Tool (ai_tool). In each node's Tool Description, clearly state what dimensions the sheet contains (e.g., customer, gender, payment method, product category, region). The AI Agent uses these descriptions to choose the correct dataset based on the user's question.
Execution prompt · Source text。Google Sheets Tool node Tool Description field (example: e-commerce orders 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.
Execution prompt · Source text。Google Sheets Tool node Tool Description field (example: 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.
Configure Edit Fields (Format Output)
Add an Edit Fields (Set) node that maps the AI Agent's output field into a clean response field. Turn OFF "Include Other Input Fields" to prevent raw JSON from appearing in the chat.
Execution prompt · Source text。Edit Fields node response field value expression
={{ $json.output.replace(/\\n/g, '\n') }}Configure Chat Response (Return Answer)
Add a Chat Response node and set the message field to {{ $json.response }} so the formatted answer is sent back to the user. Do not use {{ $json }}, or the chat will display the raw JSON object.
Test the Conversation
Save and activate the workflow, then test in the n8n chat interface with questions like "Which product category has the highest sales?" or "How are PayPal orders distributed by gender?". Verify that the AI Agent selects the correct tool, retrieves data, and returns a structured Markdown answer. [First-test safety] Before the first test, point the Google Sheets tool nodes at a test dataset, or restrict the AI Agent to read-only test sheets; reconnect production sheets only after tool calls and answers look correct.
Prompt you can copy
Setup guidance · Editorial suggestion。Setup assistant; confirm inputs and permissions before building
This block is the prompt. Ads are never placed here.
You are an n8n workflow setup assistant. The user wants to reproduce the "Business Data Analyst Chatbot" template. Assist in this order: 1. Confirm the user has an n8n instance, an OpenAI API credential, and a Google Sheets OAuth2 credential. 2. Import the workflow JSON (download or copy from https://n8n.io/workflows/15424/). 3. Configure Chat Trigger → AI Agent (including System Message) → Google Sheets Tool (including tool descriptions) → Edit Fields → Chat Response. 4. Remind the user to replace all YOUR_* placeholders with real credentials and sheet IDs. 5. Suggest testing with a single simple sheet first to verify tool selection and data retrieval.
Check credentials and sheet permissions first, then import the template; do not paste API keys directly into the JSON.
Source
Analyze business data from Google Sheets with an OpenAI chatbot · missylearnsai · n8n.io · 2026-05-01
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.