{ "name": "Outlevo: Qualified company to Telegram", "nodes": [ { "id": "507586e4-6c1f-4d4d-80db-8338f2b80acc", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -584 ], "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- **Telegram bot**: connect your Telegram bot account.\n\n**API key scopes**: `companies:read`.\n\n**Replace**: `YOUR_CHAT_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\": [\"company.qualified\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 524, "width": 620 } }, { "id": "1589b109-af4f-4499-a713-2bbd162cf48d", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-qualified-company-to-telegram", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "28f38e0a-a7df-46f5-ab2c-0839d3da5a2c" }, { "id": "75a12e66-394d-4414-a7ea-dfff0f2df94b", "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": "054422b9-a75b-4500-99e3-6f42a2531b33", "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": "92e2d148-55d4-495e-9be3-74f48d19c7b8", "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": "d8a3f9ee-7b22-49fa-b5fc-1b8004104c0b", "name": "Qualified?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "e059e905-32a6-4822-a154-ee2ecb87fd83", "leftValue": "={{ $json.event }}", "rightValue": "company.qualified", "operator": { "type": "string", "operation": "equals" } }, { "id": "2615ed4f-6d66-4a78-99b4-73c85389c08c", "leftValue": "={{ $json.sandbox === true }}", "rightValue": false, "operator": { "type": "boolean", "operation": "false" } } ], "combinator": "and" }, "options": {} } }, { "id": "c2d8f6b2-0f55-4e0b-b8ca-5be68189d7c3", "name": "Get the company", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1200, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/companies/{{ $('Qualified?').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": "1450fe1a-3ac1-4937-9bca-799fac7c89f9", "name": "Write the message", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1440, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const ev = $('Qualified?').first().json;\nconst co = $('Get the company').first().json;\nconst why = (ev.reasons || []).map((r) => (r === 'hard_constraints_pass' ? 'passes your hard rules' : r === 'no_fit_criteria' ? 'no fit criteria set yet' : /^icp_fit:/.test(r) ? `ICP fit ${r.split(':')[1]}/100` : r));\nconst name = co.name || co.domain || 'A company';\nconst text = `✅ ${name}${co.name && co.domain ? ` (${co.domain})` : ''} qualified${why.length ? `: ${why.join(', ')}` : ''}\\nhttps://app.outlevo.com/accounts/${ev.company_id}`;\nreturn [{ json: { text, subject: `Qualified: ${name}` } }];\n" } }, { "id": "1e6b5301-fc1d-4fe6-8c1b-472257386e7a", "name": "Send to Telegram", "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [ 1680, 0 ], "parameters": { "chatId": "YOUR_CHAT_ID", "text": "={{ $json.text.slice(0, 4096) }}", "additionalFields": { "appendAttribution": false, "disable_web_page_preview": true } }, "credentials": { "telegramApi": { "id": "", "name": "Telegram bot" } } } ], "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": "Qualified?", "type": "main", "index": 0 } ] ] }, "Qualified?": { "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": "Send to Telegram", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }