{ "name": "Outlevo: Failed or blocked action to Google Chat", "nodes": [ { "id": "4a4023dc-faca-4bd9-a709-40477e15d662", "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- **Outlevo API key**: a Header Auth credential, name `Authorization`, value `Bearer olv_live_…` (Settings → API keys in Outlevo).\n\n**API key scopes**: `companies:read`, `revenue_actions:read`.\n\n**Replace**: `YOUR_SPACE`, `YOUR_KEY`, `YOUR_TOKEN`.\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\": [\"revenue_action.failed\",\"revenue_action.blocked\"]}'\n```\nPut the `secret` from the answer into the Crypto credential.\n\nThen switch the workflow to **Active**.", "height": 502, "width": 620 } }, { "id": "20bdd8e4-7d8d-4282-b7e1-9c38b291be3b", "name": "Outlevo webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [ 0, 0 ], "parameters": { "httpMethod": "POST", "path": "outlevo-failed-action-to-google-chat", "responseMode": "onReceived", "options": { "rawBody": true } }, "webhookId": "39b4d597-35d4-48da-9a78-e97effef9dfe" }, { "id": "a32f5838-7adb-47a3-882c-b87098073059", "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": "2bd4c1bb-d4e5-41c0-831e-4a2de57ba5a7", "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": "0c9fbb5a-12e4-4068-86dd-1e426adfcfef", "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": "46c98a12-47eb-4cc3-bae8-620fd805151d", "name": "Failed or blocked?", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 960, 0 ], "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "b29d3be5-303f-4933-afb7-4018324fa6aa", "leftValue": "={{ ['revenue_action.failed','revenue_action.blocked'].includes($json.event) }}", "rightValue": "", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" }, "options": {} } }, { "id": "3d36d2fb-e73e-4156-82ca-2f3f3e72866b", "name": "Get the action", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1200, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/revenue-actions/{{ $('Failed or blocked?').item.json.id || 'none' }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "response": { "response": { "neverError": true } } } }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "52931c5a-29b9-4974-8330-131acb661ac1", "name": "Get the company", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1440, 0 ], "parameters": { "method": "GET", "url": "=https://api.outlevo.com/v1/companies/{{ $json.target_account_id || 'none' }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "response": { "response": { "neverError": true } } } }, "credentials": { "httpHeaderAuth": { "id": "", "name": "Outlevo API key (Authorization: Bearer olv_live_…)" } } }, { "id": "2bdd9be8-5d08-4d7f-ae7a-0a80bfed4960", "name": "Write the message", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1680, 0 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const ev = $('Failed or blocked?').first().json;\nconst a = $('Get the action').first().json;\nconst co = $('Get the company').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 LABEL = { crm_task: 'CRM task', outbound_step: 'Outbound step', ad_audience: 'Ad audience', research_request: 'Research request', handoff: 'Handoff' };\nconst kind = LABEL[ev.action_type || a.action_type] || 'Action';\nconst failed = ev.event === 'revenue_action.failed';\nconst why = s(ev.error || a.blocked_detail || ev.code || a.blocked_code);\nconst at = co.name || co.domain;\nconst text = `${failed ? '❌' : '⛔'} ${kind}${at ? ` for ${at}` : ''} ${failed ? 'failed' : 'was blocked'}${why ? `: ${why}` : ''}\\nhttps://app.outlevo.com/actions`;\nreturn [{ json: { text, subject: `${kind} ${failed ? 'failed' : 'blocked'}${at ? `: ${at}` : ''}` } }];\n" } }, { "id": "6d60afd7-790b-4d16-a3c2-4a34f473a21e", "name": "Post to Google Chat", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1920, 0 ], "parameters": { "method": "POST", "url": "https://chat.googleapis.com/v1/spaces/YOUR_SPACE/messages?key=YOUR_KEY&token=YOUR_TOKEN", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ text: $json.text }) }}", "options": {} } } ], "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": "Failed or blocked?", "type": "main", "index": 0 } ] ] }, "Failed or blocked?": { "main": [ [ { "node": "Get the action", "type": "main", "index": 0 } ], [] ] }, "Get the action": { "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": "Post to Google Chat", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1" }, "pinData": {}, "meta": { "templateCredsSetupCompleted": false } }