{ "name": "Outlevo: Do-not-email list in Airtable", "nodes": [ { "id": "2c23ed3b-3d1b-4e10-8961-a84c92e2eddb", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -650 ], "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- **Airtable**: connect your Airtable account.\n\n**API key scopes**: `contacts:read`.\n\n**Pick in the node**:\n- **Add to Airtable**: the base and the table\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\n**Columns in the table** (first row): `At`, `Why`, `Email`, `Person`, `Contact id`, `Campaign id`.\n\nThen switch the workflow to **Active**.", "height": 590, "width": 620 } }, { "id": "d9aa5b63-6414-4ff6-ad2e-5e1846c501c4", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-bounces-unsubscribes-to-airtable", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "cec3073a-cb18-4869-9c98-ce2df06bf533" }, { "id": "5a759438-a42b-4326-811e-f5e019f36fdf", "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": "2aa2f7ab-4291-4ea6-9708-01517c1e11a0", "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": "e7629c11-3328-4cfd-9c47-b17c4d865930", "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": "e7b975e9-a836-4453-ba2d-24feb7f6b4f1", "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": "d36f8bd8-a773-4f93-befe-91617c57efe8", "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": "bc3b6711-9e88-4e7a-b4dc-78103cb50373", "name": "Write the row", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1440, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// Soft bounces are left out: the address may work tomorrow.\nconst ev = $('Bounce or unsubscribe?').first().json;\nconst c = $('Get the contact').first().json;\nconst s = (v) => (v == null ? '' : typeof v === 'string' ? v : typeof v === 'object' ? JSON.stringify(v) : String(v));\nconst person = (c) => [c.first_name, c.last_name].filter(Boolean).join(' ');\nconst when = (d) => (d ? new Date(d).toUTCString().replace(/:\\d\\d GMT$/, ' UTC') : '');\nif (ev.event === 'lead.bounced' && ev.hard === false) return [];\nconst rows = [{ At: s(ev.at || ev.created_at), Why: ev.event === 'lead.unsubscribed' ? 'Unsubscribed' : 'Hard bounce', Email: s(c.email), Person: person(c), 'Contact id': s(ev.contact_id), 'Campaign id': s(ev.campaign_id) }];\nreturn rows.map((r) => ({ json: r }));\n" } }, { "id": "b3455aa2-e15e-44c4-b364-9058ab6da949", "name": "Add to Airtable", "type": "n8n-nodes-base.airtable", "typeVersion": 2.1, "position": [ 1680, 0 ], "parameters": { "authentication": "airtableTokenApi", "operation": "create", "base": { "__rl": true, "mode": "list", "value": "" }, "table": { "__rl": true, "mode": "list", "value": "" }, "columns": { "mappingMode": "autoMapInputData", "value": {}, "matchingColumns": [], "schema": [] }, "options": { "typecast": true } }, "credentials": { "airtableTokenApi": { "id": "", "name": "Airtable" } } } ], "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": "Write the row", "type": "main", "index": 0 } ] ] }, "Write the row": { "main": [ [ { "node": "Add to Airtable", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }