{ "name": "Send a WhatsApp order alert from a webhook", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "order-alert", "authentication": "headerAuth", "responseMode": "responseNode", "options": {} }, "name": "Order webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "webhookId": "order-alert" }, { "parameters": { "jsCode": "// Expects {\"phone\": \"+14155550123\", \"name\": \"Sam\", \"order_id\": \"1001\"} in the request body.\nconst { phone, name, order_id } = $json.body || {};\nconst digits = String(phone || '').replace(/\\D/g, '');\nif (!/^[1-9]\\d{9,14}$/.test(digits)) throw new Error('phone must start with the country code, with no leading 0');\nif (!order_id) throw new Error('Missing order_id in request body');\nreturn [{ json: { chatId: digits, name: name || 'there', order_id } }];" }, "name": "Check order", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 220, 0 ] }, { "parameters": { "resource": "message", "operation": "sendText", "session": "default", "chatId": "={{ $json.chatId }}", "text": "=Hi {{ $json.name }}, we have received your order {{ $json.order_id }}." }, "name": "Send order alert", "type": "n8n-nodes-whatsapp-retentionstack.whatsAppRetentionStack", "typeVersion": 1, "position": [ 440, 0 ] }, { "parameters": { "respondWith": "json", "responseBody": "={{ { sent: true } }}", "options": {} }, "name": "Respond", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.1, "position": [ 660, 0 ] }, { "parameters": { "content": "## Order alert\nYour shop POSTs `{\"phone\": \"+14155550123\", \"name\": \"Sam\", \"order_id\": \"1001\"}` and the customer gets a WhatsApp message.\n\n1. In the webhook node, create a Header Auth credential. Without it, anyone who knows the URL could send from your number.\n2. In the WhatsApp node, pick your session token credential.\n\nMessage only people who expect it.", "height": 280, "width": 460 }, "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 0, -320 ] } ], "connections": { "Order webhook": { "main": [ [ { "node": "Check order", "type": "main", "index": 0 } ] ] }, "Check order": { "main": [ [ { "node": "Send order alert", "type": "main", "index": 0 } ] ] }, "Send order alert": { "main": [ [ { "node": "Respond", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" } }