{ "name": "Outlevo: Interested reply to a Salesforce lead", "nodes": [ { "id": "23cfe464-6228-4eed-8537-3eb4c5f1bc72", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -540 ], "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- **Salesforce**: connect your Salesforce account.\n\n**API key scopes**: `contacts:read`.\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.classified\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 480, "width": 620 } }, { "id": "390a1617-fe9b-4a1e-81f2-c501908c0053", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-interested-reply-to-salesforce", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "2837386b-aea5-470f-bd59-20438f035b77" }, { "id": "14c7a763-7a1b-4b84-af07-05c26617ffad", "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": "6f0804a0-0cf6-4db8-894c-0caff974e7cf", "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": "7eb7df09-aa55-434e-9a4c-a16284634ec8", "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": "21f4ec23-d642-41c9-a5ea-80043d2bf0d1", "name": "Interested?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "9ec74e3f-d027-4a5d-bce3-69563e09b72a", "leftValue": "={{ $json.event }}", "rightValue": "lead.classified", "operator": { "type": "string", "operation": "equals" } }, { "id": "354b4405-5a41-429f-960d-b6ec2323745e", "leftValue": "={{ $json.class }}", "rightValue": "interested", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} } }, { "id": "ebddb024-1c2b-4bd4-86c7-ade6fa95b2c4", "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/{{ $('Interested?').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": "e08c7ac6-4f84-4c00-ac90-d26a7820979e", "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 } } ], "combinator": "and" }, "options": {} } }, { "id": "6ce9ae13-ab50-405b-829a-a1b9eaa4e9f6", "name": "Write the lead", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1680, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// The person and why the reply reads as interested, for the CRM record.\nconst ev = $('Interested?').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') : '');\nconst name = person(ev) || person(c) || 'Unknown';\nconst note = [`Interested reply (Outlevo)${ev.heat != null ? `, heat ${ev.heat}/5` : ''}.`, ev.reason ? `Why: ${s(ev.reason)}` : '', ev.campaign_name ? `Campaign: ${ev.campaign_name}` : '', 'https://app.outlevo.com/replies'].filter(Boolean).join('\\n');\nreturn [{ json: { name, first_name: ev.first_name || c.first_name || '', last_name: ev.last_name || c.last_name || 'Unknown', title: ev.title || c.title || '', email: c.email || '', company: ev.company_name || ev.domain || 'Unknown', website: ev.domain ? `https://${ev.domain}` : '', note } }];\n" } }, { "id": "f8f46bf3-a9ed-46e1-81e7-77c5d03b197d", "name": "Add the Salesforce lead", "type": "n8n-nodes-base.salesforce", "typeVersion": 1, "position": [ 1920, 0 ], "parameters": { "authentication": "oAuth2", "resource": "lead", "operation": "create", "company": "={{ $json.company }}", "lastname": "={{ $json.last_name }}", "additionalFields": { "firstname": "={{ $json.first_name }}", "email": "={{ $json.email }}", "title": "={{ $json.title }}", "website": "={{ $json.website }}", "description": "={{ $json.note }}" } }, "credentials": { "salesforceOAuth2Api": { "id": "", "name": "Salesforce" } } } ], "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": "Interested?", "type": "main", "index": 0 } ] ] }, "Interested?": { "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": "Write the lead", "type": "main", "index": 0 } ], [] ] }, "Write the lead": { "main": [ [ { "node": "Add the Salesforce lead", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }