{"active":false,"connections":{"Enrich Company":{"main":[[{"index":0,"node":"Score Lead","type":"main"}]]},"IF Hot Lead":{"main":[[{"index":0,"node":"Save Hot Lead","type":"main"}],[{"index":0,"node":"Save Nurture Lead","type":"main"}]]},"Lead Webhook":{"main":[[{"index":0,"node":"Enrich Company","type":"main"}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"index":0,"node":"Score Lead","type":"ai_languageModel","index":0}]]},"Parse Score":{"main":[[{"index":0,"node":"IF Hot Lead","type":"main"}]]},"Save Hot Lead":{"main":[[{"index":0,"node":"Slack Alert","type":"main"}]]},"Score Lead":{"main":[[{"index":0,"node":"Parse Score","type":"main"}]]}},"meta":{"instanceId":"","templateCredsSetupCompleted":false},"name":"AI Lead Capture → Enrich → Score → CRM Routing","nodes":[{"id":"2b3c4d5e-0000-4a5b-8c9d-000000000000","name":"Sticky Note","parameters":{"color":4,"content":"## AI Lead Capture → Enrich → Score → CRM Routing\n\n**Setup (10 min):**\n1. Create an **OpenAI** credential, select it in *OpenAI Chat Model*.\n2. In *Enrich Company*, replace the placeholder URL with your enrichment provider's company endpoint (Clearbit, Apollo, etc.) and select your **HTTP Header Auth** credential with the provider's API key.\n3. Create a **Google Sheets OAuth2** credential and a spreadsheet with two tabs: \"Hot Leads\" and \"Nurture\". Select the credential in *Save Hot Lead* and *Save Nurture Lead*, then set your spreadsheet and tab.\n4. Create a **Slack** credential, select it in *Slack Alert*, and set your channel.\n5. Point your lead form at the *Lead Webhook* URL, then activate.\n\n**How it works:** Lead Webhook → Enrich Company → AI scores 0–100 (OpenAI) → IF score ≥ 70 → Hot Leads sheet + Slack alert; lower scores go to the Nurture tab.","height":380,"width":460},"position":[160,-80],"type":"n8n-nodes-base.stickyNote","typeVersion":1},{"id":"2b3c4d5e-0001-4a5b-8c9d-111111111111","name":"Lead Webhook","parameters":{"httpMethod":"POST","options":{},"path":"lead-capture"},"position":[240,300],"type":"n8n-nodes-base.webhook","typeVersion":2,"webhookId":"cortexflow-lead-capture"},{"id":"2b3c4d5e-0002-4a5b-8c9d-222222222222","name":"Enrich Company","parameters":{"authentication":"predefinedCredentialType","method":"GET","nodeCredentialType":"httpHeaderAuth","options":{},"sendQuery":true,"url":"https://api.your-enrichment-provider.com/v1/companies?domain={{ $json.company_domain }}"},"credentials":{"httpHeaderAuth":{"id":"","name":"Enrichment Provider API Key"}},"position":[480,300],"type":"n8n-nodes-base.httpRequest","typeVersion":4.2},{"id":"2b3c4d5e-0003-4a5b-8c9d-333333333333","name":"Score Lead","parameters":{"options":{"systemMessage":"You are a lead-scoring assistant. Given lead details and enriched company data, score the lead from 0 to 100. Hot leads (70+) typically match the ideal customer profile: right company size, relevant industry, and senior decision-maker. Reply with ONLY a JSON object: {\"score\": 0-100, \"reason\": \"one short sentence\"}. Be consistent and conservative with scores."},"promptType":"define","text":"={{ 'Lead:\\nName: ' + $('Lead Webhook').item.json.name + '\\nEmail: ' + $('Lead Webhook').item.json.email + '\\nCompany: ' + $('Lead Webhook').item.json.company + '\\nDomain: ' + $('Lead Webhook').item.json.company_domain + '\\n\\nEnriched company data:\\n' + JSON.stringify($json, null, 2) }}"},"position":[720,300],"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":2.2},{"credentials":{"openAiApi":{"id":"","name":"OpenAI API"}},"id":"2b3c4d5e-0004-4a5b-8c9d-444444444444","name":"OpenAI Chat Model","parameters":{"model":{"__rl":true,"cachedResultName":"gpt-4o-mini","mode":"list","value":"gpt-4o-mini"},"options":{}},"position":[720,500],"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.2},{"id":"2b3c4d5e-0005-4a5b-8c9d-555555555555","name":"Parse Score","parameters":{"jsCode":"const lead = $('Lead Webhook').first().json;\nlet parsed = {};\ntry {\n  const raw = $input.first().json.output || '';\n  const match = raw.match(/\\{[\\s\\S]*\\}/);\n  parsed = JSON.parse(match ? match[0] : raw);\n} catch (e) { parsed = {}; }\nreturn [{ json: {\n  name: lead.name || '',\n  email: lead.email || '',\n  company: lead.company || '',\n  company_domain: lead.company_domain || '',\n  score: typeof parsed.score === 'number' ? Math.max(0, Math.min(100, Math.round(parsed.score))) : 0,\n  reason: typeof parsed.reason === 'string' ? parsed.reason : 'No reason returned'\n}}];","mode":"runOnceForAllItems"},"position":[960,300],"type":"n8n-nodes-base.code","typeVersion":2},{"id":"2b3c4d5e-0006-4a5b-8c9d-666666666666","name":"IF Hot Lead","parameters":{"conditions":{"combinator":"and","conditions":[{"id":"2b3c4d5e-c1","leftValue":"={{ $json.score }}","operator":{"type":"number","operation":"largerEqual"},"rightValue":70}],"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2}},"looseTypeValidation":true,"options":{}},"position":[1200,300],"type":"n8n-nodes-base.if","typeVersion":2.2},{"credentials":{"googleSheetsOAuth2Api":{"id":"","name":"Google Sheets API"}},"id":"2b3c4d5e-0007-4a5b-8c9d-777777777777","name":"Save Hot Lead","parameters":{"columns":{"attemptToConvertTypes":false,"convertFieldsToString":false,"mappingMode":"defineBelow","matchingColumns":[],"schema":[],"value":{"company":"={{ $json.company }}","domain":"={{ $json.company_domain }}","email":"={{ $json.email }}","name":"={{ $json.name }}","reason":"={{ $json.reason }}","score":"={{ $json.score }}"}},"documentId":{"__rl":true,"mode":"list","value":"YOUR_SPREADSHEET_ID"},"operation":"append","options":{},"resource":"sheetWithinDocument","sheetName":{"__rl":true,"cachedResultName":"Hot Leads","mode":"list","value":0}},"position":[1440,300],"type":"n8n-nodes-base.googleSheets","typeVersion":4.5},{"credentials":{"slackOAuth2Api":{"id":"","name":"Slack API"}},"id":"2b3c4d5e-0008-4a5b-8c9d-888888888888","name":"Slack Alert","parameters":{"channelId":{"__rl":true,"mode":"list","value":"C0123456789"},"operation":"post","otherOptions":{},"resource":"message","select":"channel","text":"=Hot lead: *{{ $json.name }}* ({{ $json.company }}) scored {{ $json.score }}/100. {{ $json.reason }} Contact: {{ $json.email }}"},"position":[1680,300],"type":"n8n-nodes-base.slack","typeVersion":2.3},{"credentials":{"googleSheetsOAuth2Api":{"id":"","name":"Google Sheets API"}},"id":"2b3c4d5e-0009-4a5b-8c9d-999999999999","name":"Save Nurture Lead","parameters":{"columns":{"attemptToConvertTypes":false,"convertFieldsToString":false,"mappingMode":"defineBelow","matchingColumns":[],"schema":[],"value":{"company":"={{ $json.company }}","domain":"={{ $json.company_domain }}","email":"={{ $json.email }}","name":"={{ $json.name }}","reason":"={{ $json.reason }}","score":"={{ $json.score }}"}},"documentId":{"__rl":true,"mode":"list","value":"YOUR_SPREADSHEET_ID"},"operation":"append","options":{},"resource":"sheetWithinDocument","sheetName":{"__rl":true,"cachedResultName":"Nurture","mode":"list","value":0}},"position":[1440,460],"type":"n8n-nodes-base.googleSheets","typeVersion":4.5}],"pinData":{},"settings":{"executionOrder":"v1"},"tags":[{"name":"cortexflow-template"}],"versionId":"cortexflow-ai-lead-capture-enrich-score-crm-v1"}