{ "name": "Outlevo: Website form to a qualified account", "nodes": [ { "id": "7ec1aa3a-1719-4f17-8b65-7d0f97890bca", "name": "How to set it up", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -40, -360 ], "parameters": { "content": "## How to set it up\n\n**Credentials** (n8n asks for each on first open):\n- **Form webhook secret**: a Header Auth credential with a header name and a long random value; your form or tool sends the same header.\n- **Outlevo API key**: a Header Auth credential, name `Authorization`, value `Bearer olv_live_…` (Settings → API keys in Outlevo).\n\n**API key scopes**: `companies:write`, `research:run`.\n\nYour form sends JSON with a website (or a work email) field; the webhook only takes requests that carry the header you set in its Header Auth credential.\n\nThen switch the workflow to **Active**.", "height": 300, "width": 620 } }, { "id": "8eb9a2a7-fc7f-4a83-9f8e-84e8e05654c0", "name": "Form webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-form-lead", "authentication": "headerAuth", "responseMode": "onReceived", "options": {} }, "webhookId": "a1a4f337-74ad-435d-98db-7b29d8003181", "credentials": { "httpHeaderAuth": { "id": "", "name": "Form webhook secret (a header of your choice)" } } }, { "id": "a6a4e94c-5e2b-44ca-92e8-951aa721c5a2", "name": "Find the domain", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 240, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "// Finds the company in what the form or tool sent: a website or domain field first, else the domain of a work email\n// (free mail like gmail.com does not name a company). Items without one are skipped.\nconst FREE = new Set(['gmail.com', 'googlemail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', 'live.com', 'msn.com', 'icloud.com', 'me.com', 'aol.com', 'proton.me', 'protonmail.com', 'gmx.com', 'gmx.de', 'mail.com', 'yandex.com', 'yandex.ru', 'mail.ru', 'zoho.com', 'qq.com', '163.com']);\nconst flat = (o, pre = '', out = {}) => { for (const [k, v] of Object.entries(o || {})) { if (v && typeof v === 'object' && !Array.isArray(v)) flat(v, `${pre}${k} `, out); else out[`${pre}${k}`.trim()] = Array.isArray(v) ? v.join(', ') : v; } return out; };\nconst host = (x) => { const m = String(x || '').trim().toLowerCase().match(/^(?:[a-z]+:\\/\\/)?(?:www\\.)?([a-z0-9-]+(?:\\.[a-z0-9-]+)*\\.[a-z]{2,63})(?:[/:?#]|$)/); return m ? m[1] : ''; };\nconst SITE = /website|domain|\\bsite\\b|company.?url/;\nreturn $input.all().flatMap((item) => {\n const f = flat(item.json.body);\n const keys = Object.keys(f);\n const pick = (re, skip) => { const k = keys.find((x) => re.test(x.toLowerCase()) && !(skip && skip.test(x.toLowerCase())) && String(f[x] ?? '').trim()); return k ? String(f[k]).trim() : ''; };\n const email = pick(/e-?mail/);\n const fromEmail = email.includes('@') ? email.split('@').pop().toLowerCase() : '';\n const domain = host(pick(SITE)) || (fromEmail && !FREE.has(fromEmail) ? fromEmail : '');\n if (!domain) return [];\n const out = { domain, ...({}) };\n const company = pick(/company|organi[sz]ation|business/, SITE);\n if (company) out.name = company.slice(0, 200);\n const idKey = keys.find((x) => /^(id|external.?id|crm.?id)$/i.test(x) && String(f[x] ?? '').trim());\n if (idKey) out.external_id = String(f[idKey]).slice(0, 200);\n if (item.json.row_number != null) out.row_number = item.json.row_number;\n return [{ json: out }];\n});\n" } }, { "id": "b2772296-e104-4da0-aec2-77fd878035f4", "name": "Add to Outlevo", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 480, 0 ], "parameters": { "method": "POST", "url": "=https://api.outlevo.com/v1/companies", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Idempotency-Key", "value": "={{ ('form-' + $json.domain).slice(0, 200) }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ domain: $json.domain, ...($json.name ? { name: $json.name } : {}), ...($json.external_id ? { external_id: $json.external_id } : {}) }) }}", "options": { "response": { "response": { "neverError": true, "fullResponse": true } } } }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "1f0e8683-7f15-4112-bda9-6dbe1d258900", "name": "Company id", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 720, 0 ], "parameters": { "mode": "runOnceForEachItem", "jsCode": "// 201: added. 409 COMPANY_EXISTS: already in your accounts (www., subdomains and known aliases count as the same company).\nconst body = $json.body || {};\nif ($json.statusCode === 201) return { json: { status: 'added', company_id: body.id, domain: body.domain } };\nif ($json.statusCode === 409 && body.error && body.error.code === 'COMPANY_EXISTS') return { json: { status: 'already_in_accounts', company_id: body.error.details.company_id } };\nthrow new Error(`Outlevo said ${$json.statusCode}: ${body.error ? body.error.message : 'no body'}`);\n" } }, { "id": "d6dc27b1-213d-48aa-be35-9f25ac2a72f6", "name": "Qualify it", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 960, 0 ], "parameters": { "method": "POST", "url": "=https://api.outlevo.com/v1/companies/{{ $json.company_id }}/qualify", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Idempotency-Key", "value": "={{ ('qualify-' + $json.company_id).slice(0, 200) }}" } ] }, "sendQuery": true, "queryParameters": { "parameters": [ { "name": "confirm", "value": "true" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({}) }}", "options": {} }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } } ], "connections": { "Form webhook": { "main": [ [ { "node": "Find the domain", "type": "main", "index": 0 } ] ] }, "Find the domain": { "main": [ [ { "node": "Add to Outlevo", "type": "main", "index": 0 } ] ] }, "Add to Outlevo": { "main": [ [ { "node": "Company id", "type": "main", "index": 0 } ] ] }, "Company id": { "main": [ [ { "node": "Qualify it", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }