{ "name": "Outlevo: Bounces and unsubscribes to Mailchimp", "nodes": [ { "id": "e57af24c-a72f-4fd8-a3f6-c2ef2e6fb0b9", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -606 ], "parameters": { "content": "## How to set it up\n\n**Credentials** (n8n asks for each on first open):\n- **Outlevo webhook signing secret**: a Crypto credential; paste the `secret` Outlevo returns when you register the webhook (below) as its secret.\n- **Outlevo API key**: a Header Auth credential, name `Authorization`, value `Bearer olv_live_…` (Settings → API keys in Outlevo).\n- **Mailchimp**: connect your Mailchimp account.\n\n**API key scopes**: `contacts:read`.\n\n**Pick in the node**:\n- **Unsubscribe in Mailchimp**: the audience (list); people not in it are skipped\n\n**Register the webhook** (needs a key with `webhooks:manage`): copy the Production URL of the **Outlevo webhook** node, then:\n```\ncurl -X POST https://api.outlevo.com/v1/webhooks \\\n -H \"Authorization: Bearer $OUTLEVO_KEY\" \\\n -H \"Idempotency-Key: $(uuidgen)\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"\", \"events\": [\"lead.bounced\",\"lead.unsubscribed\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 546, "width": 620 } }, { "id": "d3fbe060-c53f-4b3a-adf3-7e9be08214aa", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-bounces-unsubscribes-to-mailchimp", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "a25887b9-44f7-4ea1-b578-8396de3f6080" }, { "id": "8976fb49-83bb-403d-b57c-8fb8451ea917", "name": "Read the body", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 240, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// Outlevo signs every delivery: Outlevo-Signature: t=,v1=.\n// This node reads the raw body and the header; the Crypto node signs the same text with your secret; the next node compares.\nconst item = $input.first();\nconst raw = (await this.helpers.getBinaryDataBuffer(0, 'data')).toString('utf8');\nconst header = String((item.json.headers || {})['outlevo-signature'] || '');\nconst parts = header.split(',').map((kv) => kv.trim().split('='));\nconst t = Number((parts.find(([k]) => k === 't') || [])[1]) || 0;\nconst sigs = parts.filter(([k]) => k === 'v1').map(([, v]) => v || '');\nreturn [{ json: { raw, t, sigs, signed: `${t}.${raw}` } }];\n" } }, { "id": "4a2cb111-567f-46ba-ab5e-ac9513a74834", "name": "Sign with your secret", "type": "n8n-nodes-base.crypto", "typeVersion": 2, "position": [ 480, 0 ], "parameters": { "action": "hmac", "type": "SHA256", "value": "={{ $json.signed }}", "dataPropertyName": "hmac", "encoding": "hex" }, "credentials": { "crypto": { "id": "", "name": "Outlevo webhook signing secret" } } }, { "id": "e96e7d2d-27b5-4d18-926d-8d783e2c23aa", "name": "Check signature", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 720, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// Accept the event only if a v1 signature equals the HMAC and it was signed in the last 5 minutes; anything else stops here.\nconst { raw, t, sigs, hmac } = $input.first().json;\nconst same = (a, b) => { if (typeof a !== 'string' || a.length !== b.length) return false; let d = 0; for (let i = 0; i < a.length; i++) d |= a.charCodeAt(i) ^ b.charCodeAt(i); return d === 0; };\nif (!t || Math.abs(Date.now() / 1000 - t) > 300 || !sigs.some((s) => same(s, hmac))) throw new Error('Outlevo signature did not verify');\nconst event = JSON.parse(raw);\nreturn [{ json: { ...event.data, event_id: event.id, event: event.type, created_at: event.created_at } }];\n" } }, { "id": "c18660ec-f54e-455b-a7d9-89e9bbf1b284", "name": "Bounce or unsubscribe?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "5b072931-e374-49b7-aa03-681a39463752", "leftValue": "={{ ['lead.bounced','lead.unsubscribed'].includes($json.event) }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" }, "options": {} } }, { "id": "45f9e079-c750-43d0-b35c-09e505502197", "name": "Get the contact", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1200, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/contacts/{{ $('Bounce or unsubscribe?').item.json.contact_id || 'none' }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "response": { "response": { "neverError": true } } } }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "bdb920cb-1678-4984-8dd3-8ff854e110f6", "name": "Has an email?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1440, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "7e3a6101-64cb-4506-bd4c-982d483db535", "leftValue": "={{ $('Get the contact').first().json.email || '' }}", "rightValue": "", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true } }, { "id": "71dc72f1-2016-4817-bed2-fb7061c92479", "leftValue": "={{ $('Bounce or unsubscribe?').first().json.hard === false }}", "rightValue": false, "operator": { "type": "boolean", "operation": "false" } } ], "combinator": "and" }, "options": {} } }, { "id": "f24452da-34ab-47b7-bf9c-6d618748942c", "name": "Unsubscribe in Mailchimp", "type": "n8n-nodes-base.mailchimp", "typeVersion": 1, "position": [ 1680, 0 ], "parameters": { "resource": "member", "operation": "update", "list": "", "email": "={{ $('Get the contact').first().json.email }}", "updateFields": { "status": "unsubscribed" } }, "credentials": { "mailchimpApi": { "id": "", "name": "Mailchimp" } }, "onError": "continueRegularOutput" } ], "connections": { "Outlevo webhook": { "main": [ [ { "node": "Read the body", "type": "main", "index": 0 } ] ] }, "Read the body": { "main": [ [ { "node": "Sign with your secret", "type": "main", "index": 0 } ] ] }, "Sign with your secret": { "main": [ [ { "node": "Check signature", "type": "main", "index": 0 } ] ] }, "Check signature": { "main": [ [ { "node": "Bounce or unsubscribe?", "type": "main", "index": 0 } ] ] }, "Bounce or unsubscribe?": { "main": [ [ { "node": "Get the contact", "type": "main", "index": 0 } ], [] ] }, "Get the contact": { "main": [ [ { "node": "Has an email?", "type": "main", "index": 0 } ] ] }, "Has an email?": { "main": [ [ { "node": "Unsubscribe in Mailchimp", "type": "main", "index": 0 } ], [] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }