Talk to Your Google Sheets Data Using OpenAI Chat Agent
This workflow transforms a Google Sheet into a live, conversational database. Using an AI agent powered by OpenAI's GPT-4.1-nano model, you can ask natural language questions about your spreadsheet data and receive accurate, context-aware answers — without writing any SQL or formulas. The agent can handle queries like total campaign spend, per-channel breakdowns, month-over-month trends, and cost-per-lead calculations.
Workflow Steps
Node-by-Node Breakdown
-
Chat with Your Data (Chat Trigger) — This is the entry point of the workflow. It provides a chat interface (webhook) where users type their questions. No authentication is required to trigger the webhook; access can be secured at the workflow level.
-
Memory (Buffer Window Memory) — Stores recent conversation history so the AI can reference previous exchanges. The buffer window keeps the last few messages to maintain context without excessive token use. No authentication required.
-
OpenAI Chat Model (OpenAI GPT-4.1-nano) — The language model that processes user questions and generates answers. Uses API Key auth (you must provide an OpenAI API key). Parameters: model =
gpt-4.1-nano, no additional options configured. -
Talk to Your Data (AI Agent) — The core agent that orchestrates the conversation. It receives user input, decides which tool to call (only the Google Sheets tool is available), and returns answers. Uses API Key auth (uses the same OpenAI credential as the model). Parameters include a system message: "Google Sheets Ask-… You are Ask-… Answer questions using Google Sheets ONLY via the tool below. Be precise and conservative. There is only one dataset. Don't ask what dataset it is. Use the data tool to answer the question."
-
Analyze Data (Google Sheets Tool) — The tool the agent calls to read spreadsheet data. Uses OAuth2 authentication (Google Sheets). Parameters: document ID =
1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4("Sample Marketing Data - n8n"), sheet name = "Data" (gid: 365710158). No additional options set. -
Sticky Notes (Information Only) — Provide setup instructions and tips. Not executable nodes.
Setup Instructions
Before using this workflow, you need:
- OpenAI Account — Visit OpenAI API Keys to generate an API key. Make sure you have billing set up at OpenAI Billing and have credits available.
- Google Account — You need access to a Google Sheet. The sample uses a specific sheet, but you can point it to any sheet with a similar structure: first row = column headers, rows 2–100 = data.
To configure:
- In the OpenAI Chat Model node, create an OpenAI credential with your API key.
- In the Analyze Data node, create a Google Sheets OAuth2 credential (select your Google account and authorize access).
- Update the Document ID and Sheet Name to match your own Google Sheet.
- Optionally update the system message in the Talk to Your Data agent if you want to change the assistant's personality or instructions.
Use Cases and Variations
This workflow is perfect for:
- Marketing teams wanting instant answers about campaign performance, spend, and ROI.
- Sales operations analyzing pipeline data, deal stages, or conversion metrics.
- Small business owners asking questions about inventory, sales, or customer data without learning SQL.
Adaptations:
- Replace Google Sheets with another data source tool (e.g., Airtable, Notion, PostgreSQL, MySQL) by swapping the "Analyze Data" node.
- Add more tools to the agent (e.g., a web search tool, a calculator) to expand its capabilities.
- Change the model to GPT-4o or GPT-3.5-turbo for faster/cheaper responses.
- Add a Slack or Webhook trigger instead of the chat trigger for a different user interface.
Workflow JSON
{
"meta": {
"instanceId": "ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "5b054044-5814-47aa-99b4-0a9c5a601bad",
"name": "Analyze Data",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
784,
1328
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 365710158,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4/edit#gid=365710158",
"cachedResultName": "Data"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1UDWt0-Z9fHqwnSNfU3vvhSoYCFG6EG3E-ZewJC_CLq4/edit?usp=drivesdk",
"cachedResultName": "Sample Marketing Data - n8n"
}
},
"typeVersion": 4.7
},
{
"id": "a6869994-77e8-4f5d-916c-cc40f0b5ab7e",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
224,
1312
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-nano",
"cachedResultName": "gpt-4.1-nano"
},
"options": {}
},
// ... truncated (copy to see full JSON)How to Import This Workflow
- 1Copy the workflow JSON above using the Copy Workflow JSON button.
- 2Open your n8n instance and go to Workflows.
- 3Click Import from JSON and paste the copied workflow.
Don't have an n8n instance? Start your free trial at n8nautomation.cloud