{ "name": "Outlevo: Qualified company to Salesforce", "nodes": [ { "id": "03ef2e06-314a-4e82-8f6d-e7978194520b", "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**: `companies: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\": [\"company.qualified\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 480, "width": 620 } }, { "id": "2d870b0f-5404-44a0-ae5d-cb5400d17267", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-qualified-company-to-salesforce", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "50cd93cb-e2d9-4e0d-bbb6-43fd6d8994ad" }, { "id": "bb6b5abc-9e1c-43ce-8d24-83d4a9a7b0df", "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": "33e447ca-6c46-4c7b-8ec1-799a01cc9552", "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": "93eb46d9-1d2e-472a-aa2a-6567f1f180a8", "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": "4c50cf43-2a54-4ecd-ba1e-03983d26891c", "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": "690ee4bd-121f-4615-bcbf-75aca2616212", "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": "0358b9d4-30f4-4aa5-9a8a-637c7e443ca9", "name": "Write the note", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1440, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// The company and why it qualified, for the CRM record.\nconst ev = $('Qualified?').first().json;\nconst co = $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 note = [`Qualified by Outlevo${why.length ? `: ${why.join(', ')}` : ''}.`, co.country ? `Country: ${co.country}` : '', `https://app.outlevo.com/accounts/${ev.company_id}`].filter(Boolean).join('\\n');\nreturn [{ json: { name: co.name || co.domain, domain: co.domain, website: co.website_url || `https://${co.domain}`, country: co.country || '', note } }];\n" } }, { "id": "0b75db90-827b-4653-8cda-2e660535135a", "name": "Add the Salesforce account", "type": "n8n-nodes-base.salesforce", "typeVersion": 1, "position": [ 1680, 0 ], "parameters": { "authentication": "oAuth2", "resource": "account", "operation": "create", "name": "={{ $json.name }}", "additionalFields": { "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": "Qualified?", "type": "main", "index": 0 } ] ] }, "Qualified?": { "main": [ [ { "node": "Get the company", "type": "main", "index": 0 } ], [] ] }, "Get the company": { "main": [ [ { "node": "Write the note", "type": "main", "index": 0 } ] ] }, "Write the note": { "main": [ [ { "node": "Add the Salesforce account", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }