{ "name": "Outlevo: Interested reply to Todoist", "nodes": [ { "id": "c61248fe-3be0-485e-9f2c-431588ef7574", "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- **Todoist**: connect your Todoist account.\n\n**Pick in the node**:\n- **Create the Todoist task**: the project\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": "a9660a18-4be6-4746-a48a-45c2aec24d42", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-interested-reply-to-todoist", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "115addd6-38aa-4b05-ae1c-5c0c4bf1beb4" }, { "id": "e96a85a8-9b6b-4ad1-be52-aa4609ba4e2d", "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": "29920ff9-3a47-4091-9dfb-b3089b98f7d0", "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": "4d100ad1-cb25-4f4e-9746-06da5e2bb5a9", "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": "d5d55bb0-0715-42f2-8a2d-7993cbd5a826", "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": "6999aaad-b23d-44de-9eb8-1f399cf76d53", "name": "Write the task", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1200, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const ev = $('Interested?').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(ev) || 'someone';\nconst due = new Date(Date.now() + 864e5);\nconst name = `Answer ${who} at ${ev.company_name || ev.domain || 'their company'}`;\nconst notes = [ev.title ? `${who}, ${ev.title}` : '', ev.reason ? `Why interested: ${s(ev.reason)}` : '', ev.heat != null ? `Heat: ${ev.heat}/5` : '', ev.campaign_name ? `Campaign: ${ev.campaign_name}` : '', 'https://app.outlevo.com/replies'].filter(Boolean).join('\\n');\nreturn [{ json: { name, notes, due: due.toISOString(), due_on: due.toISOString().slice(0, 10) } }];\n" } }, { "id": "33870ec9-bad9-47ff-902b-9861b72c5ed2", "name": "Create the Todoist task", "type": "n8n-nodes-base.todoist", "typeVersion": 2.1, "position": [ 1440, 0 ], "parameters": { "operation": "create", "project": { "__rl": true, "mode": "list", "value": "" }, "content": "={{ $json.name }}", "options": { "description": "={{ $json.notes }}", "dueDate": "={{ $json.due_on }}" } }, "credentials": { "todoistApi": { "id": "", "name": "Todoist" } } } ], "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": "Write the task", "type": "main", "index": 0 } ], [] ] }, "Write the task": { "main": [ [ { "node": "Create the Todoist task", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }