| { | |
| "name": "Food Waste Assistant (Real - Safe Mode)", | |
| "nodes": [ | |
| { | |
| "parameters": { | |
| "content": "## Safe Mode Workflow\n\nThis version has a Fallback route.\nIf the Switch node doesn't match 'get_items' or 'add_item', it goes to the **Fallback** node which tells you exactly what happened.\n\nDOUBLE CLICK THE GOOGLE SHEETS NODES TO CONNECT YOUR ACCOUNT.", | |
| "height": 260, | |
| "width": 350 | |
| }, | |
| "id": "note-safe", | |
| "name": "Sticky Note", | |
| "type": "n8n-nodes-base.stickyNote", | |
| "typeVersion": 1, | |
| "position": [ | |
| 0, | |
| 0 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "httpMethod": "POST", | |
| "path": "webhook", | |
| "options": {} | |
| }, | |
| "id": "webhook-safe", | |
| "name": "Webhook (POST)", | |
| "type": "n8n-nodes-base.webhook", | |
| "typeVersion": 1, | |
| "position": [ | |
| 400, | |
| 200 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "httpMethod": "OPTIONS", | |
| "path": "webhook", | |
| "options": {} | |
| }, | |
| "id": "webhook-opt-safe", | |
| "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 | |
| } | |
| ] | |
| }, | |
| "fallbackOutput": 2 | |
| }, | |
| "id": "switch-safe", | |
| "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-safe", | |
| "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-safe", | |
| "name": "Google Sheets (Read)", | |
| "type": "n8n-nodes-base.googleSheets", | |
| "typeVersion": 4, | |
| "position": [ | |
| 850, | |
| 300 | |
| ], | |
| "credentials": { | |
| "googleSheetsOAuth2Api": { | |
| "id": "", | |
| "name": "Google Sheets account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "jsCode": "return [{ json: { success: false, message: \"Action not matched: \" + $json.body.action } }];" | |
| }, | |
| "id": "fallback-safe", | |
| "name": "Fallback Error", | |
| "type": "n8n-nodes-base.code", | |
| "typeVersion": 2, | |
| "position": [ | |
| 850, | |
| 500 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "jsCode": "const items = $input.all().map(i => i.json);\nreturn [{ json: { items: items } }];" | |
| }, | |
| "id": "fmt-read-safe", | |
| "name": "Format Read", | |
| "type": "n8n-nodes-base.code", | |
| "typeVersion": 2, | |
| "position": [ | |
| 1100, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "jsCode": "return [{ json: { success: true, message: \"Item saved\" } }];" | |
| }, | |
| "id": "fmt-add-safe", | |
| "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-safe", | |
| "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-safe", | |
| "name": "Respond OPTIONS", | |
| "type": "n8n-nodes-base.respondToWebhook", | |
| "typeVersion": 1, | |
| "position": [ | |
| 600, | |
| 600 | |
| ] | |
| } | |
| ], | |
| "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 | |
| } | |
| ], | |
| [ | |
| { | |
| "node": "Fallback Error", | |
| "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 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Fallback Error": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Respond to Webhook", | |
| "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 | |
| } | |
| ] | |
| ] | |
| } | |
| } | |
| } |