This workflow corresponds to n8n.io template #7450 — we link there as the canonical source.
This workflow follows the Agent → Execute Workflow Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "e1a46833-62a4-49ff-84c6-bdb1fc727d30",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1696,
-176
],
"parameters": {
"width": 736,
"height": 96,
"content": "## \ud83d\udcec Need Help or Want to Customize This?\n\ud83d\udce7 [robert@ynteractive.com](mailto:robert@ynteractive.com) \n\ud83d\udd17 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)"
},
"typeVersion": 1
},
{
"id": "a1988728-13a9-43f3-bffa-214a242eaf57",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
-544,
224
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "57a8f11e-4e9a-4899-88a7-c82cbbde49dd",
"name": "Get Column Info",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
-320,
640
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 467321788,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=467321788",
"cachedResultName": "Columns"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
"cachedResultName": "Sample Marketing Data"
},
"descriptionType": "manual",
"toolDescription": "Extracts a sheet\u2019s column metadata so downstream steps (querying, validation, docs) can rely on a clean, typed schema. It returns each column\u2019s name, inferred data type, and human-readable description, plus helpful profiling hints."
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.7
},
{
"id": "42696475-5531-423c-b5b1-ef07f232dabd",
"name": "When Executed by Another Workflow",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
144,
336
],
"parameters": {
"inputSource": "passthrough"
},
"typeVersion": 1.1
},
{
"id": "a224c359-aa48-4bd3-aff8-057ba8e7d448",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-128,
640
],
"parameters": {
"jsonSchemaExample": "{\n\t\"column\": \"customer\",\n\t\"aggregation\": \"sum\", \n\t\"level\": \"date, channel\"\n}\n"
},
"typeVersion": 1.3
},
{
"id": "fb666df2-8966-406c-a9be-cc6d9929b4c3",
"name": "Google Gemini Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1648,
576
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "75d28c95-61e6-4628-b447-2cce457a4a08",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-368,
304
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "0b30c4bc-8078-452c-a4e2-1c398a7a1eb0",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1696,
-48
],
"parameters": {
"width": 736,
"height": 1088,
"content": "## \ud83d\udcca Aggregate-Only Pivot Questions \u2014 One Metric at a Time\n\n### Overall Metrics\n- Show total **Spend ($)**.\n- Show total **Clicks**.\n- Show total **Conversions**.\n- Show average **Spend ($)**.\n- Show average **Clicks**.\n- Show average **Conversions**.\n- Show distinct **Customer ID** count.\n- Show distinct **Campaign** count.\n- Show distinct **Channel** count.\n\n### Single Dimension\n- Show total **Spend ($)** by Channel.\n- Show total **Spend ($)** by Campaign.\n- Show total **Clicks** by Channel.\n- Show total **Clicks** by Campaign.\n- Show total **Conversions** by Channel.\n- Show total **Conversions** by Campaign.\n- Show distinct **Customer ID** count by Channel.\n- Show distinct **Customer ID** count by Campaign.\n\n### Two Dimensions\n- Show total **Spend ($)** by Channel and Campaign.\n- Show total **Clicks** by Channel and Campaign.\n- Show total **Conversions** by Channel and Campaign.\n- Show average **Spend ($)** by Channel and Campaign.\n- Show average **Clicks** by Channel and Campaign.\n- Show average **Conversions** by Channel and Campaign.\n- Show distinct **Customer ID** count by Channel and Campaign.\n"
},
"typeVersion": 1
},
{
"id": "0d92421a-7a7b-47d2-a302-1e50a60a147c",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
96,
-160
],
"parameters": {
"color": 4,
"width": 1952,
"height": 1200,
"content": "## \u2699\ufe0f SUB-WORKFLOW - Data Processor\n\n#### 1. Configure Google Sheets Connection for Sub-Workflow\n1. Apply the same Google Sheets OAuth2 credential you created for the main workflow\n2. Update the **Get Data** node with your Sheet ID\n3. Ensure it points to your data sheet (e.g., \"Data\" sheet)\n\n#### 2. Configure Google Gemini for Output Formatting\n1. Apply the same Gemini API credential to the **Google Gemini Chat Model1** node\n2. This handles final result formatting\n\n#### 3. Link Workflows Together\n1. In the main workflow, find the **Execute Workflow - Summarize Data** node\n2. Update the workflow reference to point to your sub-workflow\n3. Ensure the sub-workflow is set to accept execution from other workflows\n"
},
"typeVersion": 1
},
{
"id": "70c73294-f496-41a1-9e61-ebadece9ee9b",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
-176
],
"parameters": {
"color": 3,
"width": 976,
"height": 1216,
"content": "## \ud83d\udccb MAIN WORKFLOW - Query Parser\n\n### Prerequisites for Main Workflow\n- Google Cloud Platform account with Gemini API access\n- Google account with access to Google Sheets\n- n8n instance (cloud or self-hosted)\n\n### Main Workflow Setup Instructions\n\n#### 1. Set Up Google Gemini Connection\n1. Go to [Google AI Studio](https://aistudio.google.com/)\n2. Sign in with your Google account\n3. Go to **Get API Key** section\n4. Create a new API key or use an existing one\n5. Copy the API key\n\n**Configure in n8n:**\n1. Click on **Google Gemini Chat Model** node\n2. Click **Create New Credential**\n3. Select **Google PaLM API**\n4. Paste your API key\n5. Save the credential\n\n#### 2. Set Up Google Sheets Connection for Main Workflow\n1. Go to [Google Cloud Console](https://console.cloud.google.com/)\n2. Create a new project or select existing one\n3. Enable the **Google Sheets API**\n4. Create OAuth 2.0 Client ID credentials\n5. In n8n, click on **Get Column Info** node\n6. Create **Google Sheets OAuth2 API** credential\n7. Complete OAuth flow\n\n#### 3. Configure Your Data Source\n**Option A: Use Sample Data**\n- The workflow is pre-configured for: [Sample Marketing Data](https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk)\n- Make a copy to your Google Drive\n\n\n#### 4. Set Up Workflow Trigger\n1. Configure how you want to trigger this workflow (webhook, manual, etc.)\n2. The workflow will output structured JSON for the sub-workflow\n\n---\n "
},
"typeVersion": 1
},
{
"id": "5445ff22-cd04-4811-91ea-1ac9d0394726",
"name": "Talk to Data with Gemini",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-368,
64
],
"parameters": {
"options": {
"systemMessage": "# MVP System Prompt \u2014 Google Sheets Ask-YOUR_OPENAI_KEY_HERE\n\nRule, you must always use the column tool for every question and followup question to know the column names\n\nif a user asks for multiple metrics, just do the first one\n\nYou are Ask-YOUR_OPENAI_KEY_HERE. Answer questions using Google Sheets ONLY via the tools below. Be precise and conservative.\n\nThere is only one dataset. dont ask what dataset it is. \nalways reference the column names tool before going to the data tool. \n\n\nOutput the data as which column is supposed to be analyzed and what is the aggregation. aggregations can only be sum, avg, count, countd, max, min. \n\nthe column needs to be written exactly as the column name is from the other tool. \n\noutput one more column for level of detail comma separated. If its a total aggregate, output \"All\" for level of detail. \n\n\noutput 4 more columns \n\n\n\n{\n\t\"column\": \"customer\",\n\t\"aggregation\": \"sum\", \n\t\"level\": \"date, channel\"\n}\n\n"
},
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "0ef3d740-e2c9-4c95-89bc-2fd66811caa9",
"name": "Execute Workflow - Summarize Data",
"type": "n8n-nodes-base.executeWorkflow",
"position": [
-80,
272
],
"parameters": {
"source": "parameter",
"options": {},
"workflowJson": "{\n \"nodes\": [\n {\n \"parameters\": {\n \"inputSource\": \"passthrough\"\n },\n \"type\": \"n8n-nodes-base.executeWorkflowTrigger\",\n \"typeVersion\": 1.1,\n \"position\": [\n 16,\n 496\n ],\n \"id\": \"42696475-5531-423c-b5b1-ef07f232dabd\",\n \"name\": \"When Executed by Another Workflow\"\n },\n {\n \"parameters\": {\n \"documentId\": {\n \"__rl\": true,\n \"value\": \"19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA\",\n \"mode\": \"list\",\n \"cachedResultName\": \"Sample Marketing Data\",\n \"cachedResultUrl\": \"https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk\"\n },\n \"sheetName\": {\n \"__rl\": true,\n \"value\": 365710158,\n \"mode\": \"list\",\n \"cachedResultName\": \"Data\",\n \"cachedResultUrl\": \"https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=365710158\"\n },\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.googleSheets\",\n \"typeVersion\": 4.7,\n \"position\": [\n 592,\n 496\n ],\n \"id\": \"c8f62b21-0027-4aa0-b6e0-d33025a8719f\",\n \"name\": \"Get row(s) in sheet\",\n \"credentials\": {\n \"googleSheetsOAuth2Api\": {\n \"id\": \"HlBW2puZbuCCq8jJ\",\n \"name\": \"Google Sheets account 3\"\n }\n }\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"aggregation\": \"countUnique\",\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1120,\n 160\n ],\n \"id\": \"3a9774c9-e95c-4dc9-9812-120907a2176a\",\n \"name\": \"Summarize\"\n },\n {\n \"parameters\": {\n \"rules\": {\n \"values\": [\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"countd\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\"\n },\n \"id\": \"297ff075-7abd-4343-8bc7-0c847c9f709a\"\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"countd\"\n },\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"id\": \"9845fa13-3f60-459c-8265-17031d741464\",\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"sum\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\",\n \"name\": \"filter.operator.equals\"\n }\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"sum\"\n },\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"id\": \"0b51e6c0-9734-4db8-a5ed-6f0fd102f03f\",\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"avg\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\",\n \"name\": \"filter.operator.equals\"\n }\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"avg\"\n },\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"id\": \"cea94521-373b-4c86-97a9-293c8c27a307\",\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"min\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\",\n \"name\": \"filter.operator.equals\"\n }\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"min\"\n },\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"id\": \"4dd86101-6290-4c33-aa4d-f7a9acfc97f8\",\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"max\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\",\n \"name\": \"filter.operator.equals\"\n }\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"max\"\n },\n {\n \"conditions\": {\n \"options\": {\n \"caseSensitive\": true,\n \"leftValue\": \"\",\n \"typeValidation\": \"strict\",\n \"version\": 2\n },\n \"conditions\": [\n {\n \"id\": \"8707085d-91b4-4016-8e30-f8574354f020\",\n \"leftValue\": \"={{ $('When Executed by Another Workflow').item.json.output.aggregation }}\",\n \"rightValue\": \"count\",\n \"operator\": {\n \"type\": \"string\",\n \"operation\": \"equals\",\n \"name\": \"filter.operator.equals\"\n }\n }\n ],\n \"combinator\": \"and\"\n },\n \"renameOutput\": true,\n \"outputKey\": \"count\"\n }\n ]\n },\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.switch\",\n \"typeVersion\": 3.2,\n \"position\": [\n 816,\n 496\n ],\n \"id\": \"81b3dbc8-d49b-4ab3-aaa3-b1fdbced4723\",\n \"name\": \"Switch\"\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"aggregation\": \"sum\",\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1136,\n 336\n ],\n \"id\": \"b33509be-33f9-43ec-b59c-b021885a9091\",\n \"name\": \"Summarize1\"\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"aggregation\": \"average\",\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1152,\n 480\n ],\n \"id\": \"8a272c6f-0844-47bc-bb3a-b3fcb6e0736c\",\n \"name\": \"Summarize2\"\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"aggregation\": \"min\",\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1168,\n 656\n ],\n \"id\": \"1b2b472d-e080-4202-aba8-2edda368c991\",\n \"name\": \"Summarize3\"\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"aggregation\": \"max\",\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1200,\n 816\n ],\n \"id\": \"cf32aa9a-79fa-4aa9-bb78-e24fb06ea9eb\",\n \"name\": \"Summarize4\"\n },\n {\n \"parameters\": {\n \"fieldsToSummarize\": {\n \"values\": [\n {\n \"field\": \"={{ $('When Executed by Another Workflow').item.json.output.column }}\"\n }\n ]\n },\n \"fieldsToSplitBy\": \"={{ $('When Executed by Another Workflow').item.json.output.level }}\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.summarize\",\n \"typeVersion\": 1.1,\n \"position\": [\n 1216,\n 976\n ],\n \"id\": \"eaafbe35-02f0-4bfe-9659-d7db0348fcdc\",\n \"name\": \"Summarize5\"\n },\n {\n \"parameters\": {\n \"aggregate\": \"aggregateAllItemData\",\n \"options\": {}\n },\n \"type\": \"n8n-nodes-base.aggregate\",\n \"typeVersion\": 1,\n \"position\": [\n 1504,\n 528\n ],\n \"id\": \"93897c1f-9403-4146-973e-3dd0febc61c4\",\n \"name\": \"Aggregate\"\n },\n {\n \"parameters\": {\n \"promptType\": \"define\",\n \"text\": \"={{ $json.data }}\",\n \"options\": {\n \"systemMessage\": \"write this into one table\"\n }\n },\n \"type\": \"@n8n/n8n-nodes-langchain.agent\",\n \"typeVersion\": 2.2,\n \"position\": [\n 1760,\n 512\n ],\n \"id\": \"6f061b81-725d-4202-a22b-15458a7ae8a0\",\n \"name\": \"AI Agent1\"\n },\n {\n \"parameters\": {\n \"options\": {}\n },\n \"type\": \"@n8n/n8n-nodes-langchain.lmChatGoogleGemini\",\n \"typeVersion\": 1,\n \"position\": [\n 1824,\n 704\n ],\n \"id\": \"fb666df2-8966-406c-a9be-cc6d9929b4c3\",\n \"name\": \"Google Gemini Chat Model1\",\n \"credentials\": {\n \"googlePalmApi\": {\n \"id\": \"Mhhn3j8lRxEgMtc5\",\n \"name\": \"Google Gemini(PaLM) Api account\"\n }\n }\n }\n ],\n \"connections\": {\n \"When Executed by Another Workflow\": {\n \"main\": [\n [\n {\n \"node\": \"Get row(s) in sheet\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Get row(s) in sheet\": {\n \"main\": [\n [\n {\n \"node\": \"Switch\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Switch\": {\n \"main\": [\n [\n {\n \"node\": \"Summarize\",\n \"type\": \"main\",\n \"index\": 0\n }\n ],\n [\n {\n \"node\": \"Summarize1\",\n \"type\": \"main\",\n \"index\": 0\n }\n ],\n [\n {\n \"node\": \"Summarize2\",\n \"type\": \"main\",\n \"index\": 0\n }\n ],\n [\n {\n \"node\": \"Summarize3\",\n \"type\": \"main\",\n \"index\": 0\n }\n ],\n [\n {\n \"node\": \"Summarize4\",\n \"type\": \"main\",\n \"index\": 0\n }\n ],\n [\n {\n \"node\": \"Summarize5\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize1\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize2\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize3\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize4\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Summarize5\": {\n \"main\": [\n [\n {\n \"node\": \"Aggregate\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Aggregate\": {\n \"main\": [\n [\n {\n \"node\": \"AI Agent1\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n },\n \"Google Gemini Chat Model1\": {\n \"ai_languageModel\": [\n [\n {\n \"node\": \"AI Agent1\",\n \"type\": \"ai_languageModel\",\n \"index\": 0\n }\n ]\n ]\n }\n },\n \"pinData\": {\n \"When Executed by Another Workflow\": [\n {\n \"output\": {\n \"column\": \"Spend ($)\",\n \"aggregation\": \"sum\",\n \"level\": \"Channel\"\n }\n }\n ]\n },\n \"meta\": {\n \"templateCredsSetupCompleted\": true,\n \"instanceId\": \"ad0113c344ee237399e44e9f11798b05baeb83a6196d514a9ae9d2ad71c3b5c9\"\n }\n}"
},
"typeVersion": 1.2
},
{
"id": "c8f62b21-0027-4aa0-b6e0-d33025a8719f",
"name": "Get Data",
"type": "n8n-nodes-base.googleSheets",
"position": [
448,
336
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 365710158,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit#gid=365710158",
"cachedResultName": "Data"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19aUQYZq02qHsCelO4eeV4sx_MTJJupC5qe0gDLQBtRA/edit?usp=drivesdk",
"cachedResultName": "Sample Marketing Data"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.7
},
{
"id": "81b3dbc8-d49b-4ab3-aaa3-b1fdbced4723",
"name": "Type of Aggregation",
"type": "n8n-nodes-base.switch",
"position": [
704,
336
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "countd",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "297ff075-7abd-4343-8bc7-0c847c9f709a",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "countd"
}
]
},
"renameOutput": true
},
{
"outputKey": "sum",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9845fa13-3f60-459c-8265-17031d741464",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "sum"
}
]
},
"renameOutput": true
},
{
"outputKey": "avg",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0b51e6c0-9734-4db8-a5ed-6f0fd102f03f",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "avg"
}
]
},
"renameOutput": true
},
{
"outputKey": "min",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cea94521-373b-4c86-97a9-293c8c27a307",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "min"
}
]
},
"renameOutput": true
},
{
"outputKey": "max",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "4dd86101-6290-4c33-aa4d-f7a9acfc97f8",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "max"
}
]
},
"renameOutput": true
},
{
"outputKey": "count",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8707085d-91b4-4016-8e30-f8574354f020",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('When Executed by Another Workflow').item.json.output.aggregation }}",
"rightValue": "count"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "93897c1f-9403-4146-973e-3dd0febc61c4",
"name": "Bring All Data together",
"type": "n8n-nodes-base.aggregate",
"position": [
1392,
368
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "3a9774c9-e95c-4dc9-9812-120907a2176a",
"name": "Count Unique",
"type": "n8n-nodes-base.summarize",
"position": [
992,
-96
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}",
"aggregation": "countUnique"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "b33509be-33f9-43ec-b59c-b021885a9091",
"name": "Sum",
"type": "n8n-nodes-base.summarize",
"position": [
1024,
64
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}",
"aggregation": "sum"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "8a272c6f-0844-47bc-bb3a-b3fcb6e0736c",
"name": "Average",
"type": "n8n-nodes-base.summarize",
"position": [
1040,
192
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}",
"aggregation": "average"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "1b2b472d-e080-4202-aba8-2edda368c991",
"name": "Min",
"type": "n8n-nodes-base.summarize",
"position": [
1040,
368
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}",
"aggregation": "min"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "cf32aa9a-79fa-4aa9-bb78-e24fb06ea9eb",
"name": "Max",
"type": "n8n-nodes-base.summarize",
"position": [
1056,
544
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}",
"aggregation": "max"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "eaafbe35-02f0-4bfe-9659-d7db0348fcdc",
"name": "Count",
"type": "n8n-nodes-base.summarize",
"position": [
1056,
688
],
"parameters": {
"options": {},
"fieldsToSplitBy": "={{ $('When Executed by Another Workflow').item.json.output.level }}",
"fieldsToSummarize": {
"values": [
{
"field": "={{ $('When Executed by Another Workflow').item.json.output.column }}"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "6f061b81-725d-4202-a22b-15458a7ae8a0",
"name": "Write into Table Output",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1648,
352
],
"parameters": {
"text": "={{ $json.data }}",
"options": {
"systemMessage": "write this into one table. output as dimensions, then metrics"
},
"promptType": "define"
},
"typeVersion": 2.2
}
],
"connections": {
"Max": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Min": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Sum": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Count": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Average": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Get Data": {
"main": [
[
{
"node": "Type of Aggregation",
"type": "main",
"index": 0
}
]
]
},
"Count Unique": {
"main": [
[
{
"node": "Bring All Data together",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Talk to Data with Gemini",
"type": "ai_memory",
"index": 0
}
]
]
},
"Get Column Info": {
"ai_tool": [
[
{
"node": "Talk to Data with Gemini",
"type": "ai_tool",
"index": 0
}
]
]
},
"Type of Aggregation": {
"main": [
[
{
"node": "Count Unique",
"type": "main",
"index": 0
}
],
[
{
"node": "Sum",
"type": "main",
"index": 0
}
],
[
{
"node": "Average",
"type": "main",
"index": 0
}
],
[
{
"node": "Min",
"type": "main",
"index": 0
}
],
[
{
"node": "Max",
"type": "main",
"index": 0
}
],
[
{
"node": "Count",
"type": "main",
"index": 0
}
]
]
},
"Bring All Data together": {
"main": [
[
{
"node": "Write into Table Output",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Talk to Data with Gemini",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Talk to Data with Gemini",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Talk to Data with Gemini": {
"main": [
[
{
"node": "Execute Workflow - Summarize Data",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model1": {
"ai_languageModel": [
[
{
"node": "Write into Table Output",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Execute Workflow - Summarize Data": {
"main": [
[]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Get Data",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
googlePalmApigoogleSheetsOAuth2Api
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This n8n workflow template creates an efficient data analysis system that uses Google Gemini AI to interpret user questions about spreadsheet data and processes them through a specialized sub-workflow for optimized token usage and faster responses. Smart Query Parsing: Uses…
Source: https://n8n.io/workflows/7450/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
> AI-powered nutrition assistant for Telegram — log meals, set goals, and get personalized daily reports with Google Sheets integration.
This automation is designed to help you generate AI-powered music tracks, cover art, and fully rendered music videos — all triggered from a simple Telegram chat and managed via Google Sheets.
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
This workflow is perfect for creators, solopreneurs, and personal brands who want to consistently publish bold, high-performing content on X (Twitter) — without writing a single line themselves. After
AI Blog Publisher – Automated Blog Content Workflow This workflow is designed for individuals and teams who regularly publish content on their blog and want to automate the entire process from start t