{ "name": "Outlevo: Classified replies log in Google Sheets", "nodes": [ { "id": "461239a9-1ad2-4c51-a6e1-506e1c9a3eaf", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -562 ], "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- **Google Sheets**: connect your Google Sheets account.\n\n**Replace**: `YOUR_SHEET_ID`.\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\n**Columns in the \"Reply classes\" sheet** (first row): `At`, `Class`, `Heat`, `Reason`, `Person`, `Job title`, `Company`, `Domain`, `Campaign`, `Link`.\n\nThen switch the workflow to **Active**.", "height": 502, "width": 620 } }, { "id": "61ec7c1a-de62-4507-a614-5edfd64117b1", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-classified-reply-to-sheet", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "3dc2faf7-5e72-485b-827b-8e0ef2e92ac3" }, { "id": "b59df20b-b1bc-4047-9bff-623e4ccfb7b5", "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": "8ad74607-64d5-45f0-871c-964cf3a06695", "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": "e777c645-c18f-4043-b051-aa50cd540565", "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": "2876797b-5b8b-472e-b2f5-f0b4358917d2", "name": "Classified?", "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" } } ], "combinator": "and" }, "options": {} } }, { "id": "bfdcea98-fdbc-466b-bf50-25092495a525", "name": "Write the row", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1200, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const ev = $('Classified?').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 rows = [{ At: s(ev.at || ev.created_at), Class: s(ev.class), Heat: s(ev.heat), Reason: s(ev.reason), Person: person(ev), 'Job title': s(ev.title), Company: s(ev.company_name), Domain: s(ev.domain), Campaign: s(ev.campaign_name), Link: 'https://app.outlevo.com/replies' }];\nreturn rows.map((r) => ({ json: r }));\n" } }, { "id": "c8513338-02ef-436c-b3ea-895bad4a5f6c", "name": "Add to the sheet", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [ 1440, 0 ], "parameters": { "operation": "append", "documentId": { "__rl": true, "mode": "url", "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit" }, "sheetName": { "__rl": true, "mode": "name", "value": "Reply classes" }, "columns": { "mappingMode": "autoMapInputData", "value": {}, "matchingColumns": [], "schema": [] }, "options": {} }, "credentials": { "googleSheetsOAuth2Api": { "id": "", "name": "Google Sheets" } } } ], "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": "Classified?", "type": "main", "index": 0 } ] ] }, "Classified?": { "main": [ [ { "node": "Write the row", "type": "main", "index": 0 } ], [] ] }, "Write the row": { "main": [ [ { "node": "Add to the sheet", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }