{ "name": "Food Waste Assistant (Real - Google Sheets)", "nodes": [ { "parameters": { "content": "## Real Database Setup (Google Sheets)\n\nThis workflow reads/writes to a Google Sheet.\n\n### Setup Steps\n1. Create a Google Sheet.\n2. Create header row: `id`, `name`, `quantity`, `expiryDate`, `category`.\n3. Double-click **Google Sheets** nodes to authenticate.\n4. Select your Sheet in the node settings.", "height": 240, "width": 350 }, "id": "note-real", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 0, 0 ] }, { "parameters": { "httpMethod": "POST", "path": "webhook", "options": {} }, "id": "webhook-real", "name": "Webhook (POST)", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [ 400, 200 ] }, { "parameters": { "httpMethod": "OPTIONS", "path": "webhook", "options": {} }, "id": "webhook-opt-real", "name": "Webhook (OPTIONS)", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [ 400, 500 ] }, { "parameters": { "dataType": "string", "value1": "={{ $json.body.action }}", "rules": { "rules": [ { "value2": "add_item", "output": 0 }, { "value2": "get_items", "output": 1 } ] } }, "id": "switch-real", "name": "Switch Action", "type": "n8n-nodes-base.switch", "typeVersion": 2, "position": [ 600, 200 ] }, { "parameters": { "operation": "append", "sheetId": { "__rl": true, "mode": "fromStr" }, "range": "A:E", "options": {} }, "id": "gs-add", "name": "Google Sheets (Add)", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4, "position": [ 850, 100 ], "credentials": { "googleSheetsOAuth2Api": { "id": "", "name": "Google Sheets account" } } }, { "parameters": { "operation": "read", "sheetId": { "__rl": true, "mode": "fromStr" }, "range": "A:E", "options": {} }, "id": "gs-read", "name": "Google Sheets (Read)", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4, "position": [ 850, 300 ], "credentials": { "googleSheetsOAuth2Api": { "id": "", "name": "Google Sheets account" } } }, { "parameters": { "jsCode": "const items = $input.all().map(i => i.json);\nreturn [{ json: { items: items } }];" }, "id": "format-read", "name": "Format Read", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1100, 300 ] }, { "parameters": { "jsCode": "return [{ json: { success: true, message: \"Item saved to Sheets\" } }];" }, "id": "format-add", "name": "Format Add", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1100, 100 ] }, { "parameters": { "options": { "responseHeaders": { "entries": [ { "name": "Access-Control-Allow-Origin", "value": "*" }, { "name": "Access-Control-Allow-Methods", "value": "POST, OPTIONS" }, { "name": "Access-Control-Allow-Headers", "value": "*" } ] } } }, "id": "resp-real", "name": "Respond to Webhook", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1, "position": [ 1350, 200 ] }, { "parameters": { "options": { "responseHeaders": { "entries": [ { "name": "Access-Control-Allow-Origin", "value": "*" }, { "name": "Access-Control-Allow-Methods", "value": "POST, OPTIONS" }, { "name": "Access-Control-Allow-Headers", "value": "*" } ] } } }, "id": "resp-opt-real", "name": "Respond OPTIONS", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1, "position": [ 600, 500 ] } ], "connections": { "Webhook (POST)": { "main": [ [ { "node": "Switch Action", "type": "main", "index": 0 } ] ] }, "Webhook (OPTIONS)": { "main": [ [ { "node": "Respond OPTIONS", "type": "main", "index": 0 } ] ] }, "Switch Action": { "main": [ [ { "node": "Google Sheets (Add)", "type": "main", "index": 0 } ], [ { "node": "Google Sheets (Read)", "type": "main", "index": 0 } ] ] }, "Google Sheets (Add)": { "main": [ [ { "node": "Format Add", "type": "main", "index": 0 } ] ] }, "Google Sheets (Read)": { "main": [ [ { "node": "Format Read", "type": "main", "index": 0 } ] ] }, "Format Add": { "main": [ [ { "node": "Respond to Webhook", "type": "main", "index": 0 } ] ] }, "Format Read": { "main": [ [ { "node": "Respond to Webhook", "type": "main", "index": 0 } ] ] } } }