{"active":false,"connections":{"Chat Trigger":{"main":[[{"index":0,"node":"Read Sheet Rows","type":"main"}]]},"Digest Schedule":{"main":[[{"index":0,"node":"Read Sheet (Digest)","type":"main"}]]},"Format Rows as Table":{"main":[[{"index":0,"node":"AI Agent","type":"main"}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"index":0,"node":"AI Agent","type":"ai_languageModel"}]]},"Read Sheet (Digest)":{"main":[[{"index":0,"node":"Summarize Changes","type":"main"}]]},"Read Sheet Rows":{"main":[[{"index":0,"node":"Format Rows as Table","type":"main"}]]},"Summarize Changes":{"main":[[{"index":0,"node":"Send Digest Email","type":"main"}]]}},"meta":{"instanceId":"","templateCredsSetupCompleted":false},"name":"Talk to Your Data: Sheets Chat & Digests","nodes":[{"id":"b2c3d4e5-0001-4a5b-8c9d-111111111111","name":"Chat Trigger","parameters":{"options":{},"webhookId":"cortexflow-sheets-chat"},"position":[240,300],"type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1.2},{"credentials":{"googleSheetsOAuth2Api":{"id":"","name":"Google Sheets account"}},"id":"b2c3d4e5-0002-4a5b-8c9d-222222222222","name":"Read Sheet Rows","parameters":{"documentId":{"__rl":true,"mode":"list","value":""},"operation":"read","options":{},"sheetName":{"__rl":true,"mode":"list","value":"Sheet1"}},"position":[480,300],"type":"n8n-nodes-base.googleSheets","typeVersion":4.2},{"id":"b2c3d4e5-0003-4a5b-8c9d-333333333333","name":"Format Rows as Table","parameters":{"assignments":{"assignments":[{"id":"fmt-row-1","name":"row","type":"string","value":"={{ Object.entries($json).map(([k, v]) => `${k}: ${v}`).join(' | ') }}"}]},"includeOtherFields":true,"mode":"manual","options":{}},"position":[720,300],"type":"n8n-nodes-base.set","typeVersion":3.4},{"id":"b2c3d4e5-0004-4a5b-8c9d-444444444444","name":"AI Agent","parameters":{"options":{"systemMessage":"You answer questions about a spreadsheet. You receive the sheet data as a plain-text table in the user message. Answer ONLY from the provided data. If the answer is not in the data, say \"not in the data\" instead of guessing. Never invent numbers."},"promptType":"define","text":"={{ 'Here is the spreadsheet data:\n\n' + $items().map(i => i.json.row).join('\n') + '\n\nQuestion: ' + $('Chat Trigger').item.json.chatInput }}"},"position":[960,300],"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2},{"credentials":{"openAiApi":{"id":"","name":"OpenAI API"}},"id":"b2c3d4e5-0005-4a5b-8c9d-555555555555","name":"OpenAI Chat Model","parameters":{"model":{"__rl":true,"cachedResultName":"gpt-4o-mini","mode":"list","value":"gpt-4o-mini"},"options":{}},"position":[960,500],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"id":"b2c3d4e5-0006-4a5b-8c9d-666666666666","name":"Digest Schedule","parameters":{"rule":{"interval":[{"cronExpression":"0 8 * * *","field":"cron"}]}},"position":[240,700],"type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2},{"credentials":{"googleSheetsOAuth2Api":{"id":"","name":"Google Sheets account"}},"id":"b2c3d4e5-0007-4a5b-8c9d-777777777777","name":"Read Sheet (Digest)","parameters":{"documentId":{"__rl":true,"mode":"list","value":""},"operation":"read","options":{},"sheetName":{"__rl":true,"mode":"list","value":"Sheet1"}},"position":[480,700],"type":"n8n-nodes-base.googleSheets","typeVersion":4.2},{"credentials":{"openAiApi":{"id":"","name":"OpenAI API"}},"id":"b2c3d4e5-0008-4a5b-8c9d-888888888888","name":"Summarize Changes","parameters":{"messages":{"values":[{"content":"=Summarize the key figures and notable changes in this spreadsheet data. Reply with a short bullet-point digest:\n\n{{ $items().map(i => Object.entries(i.json).map(([k,v]) => `${k}: ${v}`).join(' | ')).join('\n') }}","role":"user"}]},"model":{"__rl":true,"cachedResultName":"gpt-4o-mini","mode":"list","value":"gpt-4o-mini"},"operation":"message","options":{},"resource":"text"},"position":[720,700],"type":"n8n-nodes-base.openAi","typeVersion":1},{"credentials":{"gmailOAuth2":{"id":"","name":"Gmail account"}},"id":"b2c3d4e5-0009-4a5b-8c9d-999999999999","name":"Send Digest Email","parameters":{"emailType":"text","message":"={{ $json.message.content }}","operation":"send","options":{},"resource":"message","sendTo":"you@example.com","subject":"=Daily sheet digest — {{ $now.toFormat('yyyy-MM-dd') }}"},"position":[960,700],"type":"n8n-nodes-base.gmail","typeVersion":2.1},{"id":"b2c3d4e5-0010-4a5b-8c9d-aaaaaaaaaaaa","name":"Sticky Note","parameters":{"color":4,"content":"## Talk to Your Data: Sheets Chat & Digests\n\n**Two independent chains:**\n**Chain 1 — Chat with your sheet:** Chat Trigger → Read Sheet Rows → Format Rows as Table → AI Agent. The agent answers ONLY from your sheet data (says \"not in the data\" otherwise).\n**Chain 2 — Daily digest (8:00 AM):** Digest Schedule → Read Sheet (Digest) → Summarize Changes → Send Digest Email.\n\n**Setup:**\n1. Create a Google Sheets OAuth2 API credential; point both sheet nodes at your Document + Sheet tab.\n2. Create an OpenAI credential; select it in OpenAI Chat Model and Summarize Changes.\n3. Create a Gmail OAuth2 API credential; replace you@example.com in Send Digest Email with your address.\n4. Activate the workflow.","height":300,"width":420},"position":[160,-80],"type":"n8n-nodes-base.stickyNote","typeVersion":1}],"pinData":{},"settings":{"executionOrder":"v1"},"tags":[{"name":"cortexflow-template"}],"versionId":"cortexflow-sheets-data-chat-digests-v1"}