{ "name": "Outlevo: New reply to Slack", "nodes": [ { "id": "42c2e1d4-ca04-47f7-bb51-f1a465d18e89", "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- **Slack**: connect your Slack account.\n\n**API key scopes**: `companies:read`, `contacts:read`.\n\n**Pick in the node**:\n- **Post to Slack**: the channel (#sales by default)\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.replied\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 546, "width": 620 } }, { "id": "e3b8c098-302f-461e-b819-e479f485c17a", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-reply-to-slack", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "c56d883d-1bc5-494d-bed2-06e9af422c2f" }, { "id": "c3b32791-f9e5-4161-a6b4-fb94c9d9492a", "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": "1f1ab932-ad84-4091-bf10-fc5fee300719", "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": "ac966599-4895-46e1-9501-9b5e062614c3", "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": "369cf1cf-47b2-4f40-9b49-326f4c6dc653", "name": "A reply?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "8e515c03-d8b9-47d5-b3c8-ff4d852f942a", "leftValue": "={{ $json.event }}", "rightValue": "lead.replied", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "options": {} } }, { "id": "d3a7fdc7-0f33-4ae5-aecc-23f599a4f6c6", "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/{{ $('A reply?').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": "b76de658-c396-4226-bda3-c68275c055de", "name": "Get the company", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1440, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/companies/{{ $('A reply?').item.json.company_id || 'none' }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "response": { "response": { "neverError": true } } } }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "23e7cfbb-77c3-45e7-9a47-45e19e77969a", "name": "Write the message", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1680, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const ev = $('A reply?').first().json;\nconst c = $('Get the contact').first().json;\nconst co = $('Get the company').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 who = person(c) || 'Someone';\nconst at = co.name || co.domain || 'their company';\nconst said = s(ev.reply_text).trim();\nconst via = ev.channel === 'linkedin' ? 'LinkedIn' : 'email';\nconst text = `💬 ${who}${c.title ? ` (${c.title})` : ''} at ${at} replied on ${via}${said ? `:\\n> ${said.slice(0, 800).split('\\n').join('\\n> ')}` : '.'}\\nhttps://app.outlevo.com/replies`;\nreturn [{ json: { text, subject: `Reply from ${who} at ${at}` } }];\n" } }, { "id": "80fb0c34-77ab-42c1-9e34-4258f4913eda", "name": "Post to Slack", "type": "n8n-nodes-base.slack", "typeVersion": 2.2, "position": [ 1920, 0 ], "parameters": { "resource": "message", "operation": "post", "select": "channel", "channelId": { "__rl": true, "mode": "name", "value": "#sales" }, "text": "={{ $json.text }}", "otherOptions": { "includeLinkToWorkflow": false } }, "credentials": { "slackApi": { "id": "", "name": "Slack" } } } ], "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": "A reply?", "type": "main", "index": 0 } ] ] }, "A reply?": { "main": [ [ { "node": "Get the contact", "type": "main", "index": 0 } ], [] ] }, "Get the contact": { "main": [ [ { "node": "Get the company", "type": "main", "index": 0 } ] ] }, "Get the company": { "main": [ [ { "node": "Write the message", "type": "main", "index": 0 } ] ] }, "Write the message": { "main": [ [ { "node": "Post to Slack", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }