{
  "id": "4fPw9brL0Vqdez5w",
  "name": "Score inbound leads with Claude AI and route in HubSpot by lifecycle stage",
  "tags": [],
  "nodes": [
    {
      "id": "3e90edc1-f121-41fa-9300-e0903379a012",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        80
      ],
      "parameters": {
        "width": 480,
        "height": 896,
        "content": "## Score inbound leads with Claude AI and route in HubSpot by lifecycle stage\n\n### How it works\n\nThis workflow receives inbound form leads, ensures the required HubSpot AI scoring properties exist, and enriches the lead with company website and news context. It builds a profile for Claude AI to score, parses the resulting score and tier, then upserts the contact in HubSpot. Finally, it routes the lead by tier: hot leads create a deal and alert sales, while warm and cold leads receive appropriate email follow-up.\n\n### Setup steps\n\n- Configure the webhook URL in the inbound form so submitted lead data reaches the workflow.\n- Add HubSpot credentials/API access for property creation, contact upsert, and deal creation nodes.\n- Add Anthropic API credentials for the Claude AI lead scoring and company news/search requests.\n- Configure Gmail credentials and email templates for hot, warm, and cold lead responses.\n- Configure Slack credentials and set the sales Slack channel in the Lead Scoring Config node.\n- Review the ICP description and hot/warm score thresholds in the Lead Scoring Config node before activating.\n\n### Customization\n\nAdjust the ICP, score thresholds, HubSpot property names, lifecycle routing rules, Slack channel, and email copy to match your sales process."
      },
      "typeVersion": 1
    },
    {
      "id": "dacd4be4-89d4-4ce2-8ba8-7f9a30ff21ab",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 784,
        "height": 304,
        "content": "## Receive and prepare HubSpot\n\nCaptures a new form submission and ensures the custom HubSpot properties needed to store AI lead score, tier, and reasoning exist before scoring begins."
      },
      "typeVersion": 1
    },
    {
      "id": "33166496-db4d-4f20-ba46-0568ca15eed7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 336,
        "content": "## Configure scoring inputs\n\nDefines the scoring parameters, including ICP details and tier thresholds, then extracts the company domain from the lead data for enrichment."
      },
      "typeVersion": 1
    },
    {
      "id": "f8e427e1-d501-4e26-92de-3cc3f562b6ce",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 304,
        "content": "## Research company context\n\nFetches the company website, prepares a research query, and searches for company news or contextual signals to support AI scoring."
      },
      "typeVersion": 1
    },
    {
      "id": "62403742-6ee3-4791-ae78-04be536d2aba",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        288
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 320,
        "content": "## Score lead with Claude\n\nBuilds a structured lead profile, sends it to Claude for scoring, and parses the AI response into usable score, tier, and rationale fields."
      },
      "typeVersion": 1
    },
    {
      "id": "8d282d84-8234-4678-ac9c-adc9024c1f4c",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2864,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 336,
        "content": "## Save scored contact\n\nUpserts the scored lead as a HubSpot contact and enriches the workflow data with the HubSpot contact ID and AI scoring fields for downstream routing."
      },
      "typeVersion": 1
    },
    {
      "id": "ab73c0f9-0746-4458-a826-d3afae7a908f",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3280,
        240
      ],
      "parameters": {
        "color": 7,
        "height": 400,
        "content": "## Route by tier\n\nBranches the workflow based on the AI lead tier so hot, warm, and cold leads receive different follow-up actions."
      },
      "typeVersion": 1
    },
    {
      "id": "24c070df-7164-423e-aeb9-3caf1074179b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3552,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 304,
        "content": "## Handle hot leads\n\nFor hot leads, creates a HubSpot deal, alerts the sales team in Slack, and sends an immediate hot lead email."
      },
      "typeVersion": 1
    },
    {
      "id": "70191e6e-a5db-4138-8b2b-fddcc1f6b9ea",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3552,
        416
      ],
      "parameters": {
        "color": 7,
        "height": 576,
        "content": "## Send nurture emails\n\nSends tier-specific Gmail follow-up messages for warm and cold leads that do not enter the hot-lead sales path."
      },
      "typeVersion": 1
    },
    {
      "id": "2d3c78ad-8ac3-40ba-b83b-cdb9d96472e2",
      "name": "When Lead Submitted",
      "type": "n8n-nodes-base.webhook",
      "position": [
        416,
        448
      ],
      "parameters": {
        "path": "lead-intake",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "a13ae858-9f87-438d-b031-9abc8f24d9fd",
      "name": "Post Lead Score Property",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        608,
        448
      ],
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/properties/contacts",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "jsonBody": "{\"name\":\"ai_lead_score\",\"label\":\"AI Lead Score (1-10)\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"contactinformation\"}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f2315c1c-a88e-4e93-9826-59bd6045e438",
      "name": "Post Lead Tier Property",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        816,
        448
      ],
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/properties/contacts",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "jsonBody": "{\"name\":\"ai_lead_tier\",\"label\":\"AI Lead Tier\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"contactinformation\"}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "68effb53-246b-4c24-a7ed-3c211c100afa",
      "name": "Post Score Reason Property",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        448
      ],
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/properties/contacts",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "jsonBody": "{\"name\":\"ai_score_reason\",\"label\":\"AI Score Reason\",\"type\":\"string\",\"fieldType\":\"text\",\"groupName\":\"contactinformation\"}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a62c2f5e-325d-4602-9f0a-523f8154f82a",
      "name": "Set Lead Scoring Params",
      "type": "n8n-nodes-base.set",
      "position": [
        1248,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cfg-001",
              "name": "my_icp",
              "type": "string",
              "value": "B2B SaaS companies with 10-200 employees in finance, HR, or operations. Decision makers are VP of Operations, CTO, Head of Engineering, or Finance Director. High-value buying signals: approved budget, hard deadline, pain around manual or broken processes."
            },
            {
              "id": "cfg-002",
              "name": "hot_threshold",
              "type": "number",
              "value": 7
            },
            {
              "id": "cfg-003",
              "name": "warm_threshold",
              "type": "number",
              "value": 4
            },
            {
              "id": "cfg-004",
              "name": "sales_slack_channel",
              "type": "string",
              "value": "C0XXXXXXXXX"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ed81bbc1-7ad9-4707-9141-28e2de6d2eda",
      "name": "Extract Domain from Email",
      "type": "n8n-nodes-base.code",
      "position": [
        1440,
        448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const email = $('When Lead Submitted').first().json.body.email || '';\nconst domain = email.includes('@') ? email.split('@')[1].toLowerCase().trim() : '';\nreturn { domain };"
      },
      "typeVersion": 2
    },
    {
      "id": "0a27c4d6-1359-477d-b44a-9da030818b9d",
      "name": "Get Company Website",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1664,
        448
      ],
      "parameters": {
        "url": "={{ 'https://' + $json.domain }}",
        "options": {
          "timeout": 10000,
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          },
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b6b8052d-dcc7-4a60-91ff-af227016047f",
      "name": "Compile Lead Profile",
      "type": "n8n-nodes-base.code",
      "position": [
        2288,
        448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const newsResp = $input.item.json;\nlet newsText = 'No third-party intelligence found';\ntry {\n  const blocks = (newsResp.content || []).filter(b => b.type === 'text');\n  if (blocks.length > 0) newsText = blocks[blocks.length - 1].text || 'No results';\n} catch(e) { newsText = 'News search error: ' + String(e); }\n\nconst websiteResp = $('Get Company Website').first().json;\nlet rawHtml = '';\nif (websiteResp.body && typeof websiteResp.body === 'string') rawHtml = websiteResp.body;\nelse if (websiteResp.data && typeof websiteResp.data === 'string') rawHtml = websiteResp.data;\nelse if (typeof websiteResp === 'string') rawHtml = websiteResp;\n\nconst websiteText = rawHtml\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, ' ')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, ' ')\n  .replace(/<link[^>]*>/gi, ' ')\n  .replace(/<[^>]{1,500}>/g, ' ')\n  .replace(/https?:\\/\\/\\S+/g, ' ')\n  .replace(/\\s+/g, ' ')\n  .replace(/[^\\x20-\\x7E]/g, '')\n  .trim()\n  .substring(0, 1200) || 'Website not accessible';\n\nconst body   = $('When Lead Submitted').first().json.body;\nconst config = $('Set Lead Scoring Params').first().json;\nconst domain = $('Extract Domain from Email').first().json.domain;\n\nconst leadName     = body.name       || '';\nconst leadEmail    = body.email      || '';\nconst leadCompany  = body.company    || '';\nconst leadJobTitle = body.job_title  || '';\nconst leadMessage  = body.message    || '';\nconst myIcp        = config.my_icp;\n\nconst prompt = 'You are a B2B sales qualification expert. Score this inbound lead against the ICP.\\n\\n'\n  + 'ICP:\\n' + myIcp + '\\n\\n'\n  + 'Lead Information:\\n'\n  + '- Name: '      + leadName      + '\\n'\n  + '- Email: '     + leadEmail     + '\\n'\n  + '- Company: '   + leadCompany   + '\\n'\n  + '- Job Title: ' + leadJobTitle  + '\\n'\n  + '- Message: '   + (leadMessage || '(no message provided)') + '\\n\\n'\n  + 'Company Website (stripped homepage text):\\n'\n  + websiteText + '\\n\\n'\n  + 'Third-Party Intelligence (news, funding, press from external sources):\\n'\n  + newsText + '\\n\\n'\n  + 'SCORING RULES \u2014 follow these strictly:\\n'\n  + '1. Treat the form message as LOW-RELIABILITY self-reported data. Anyone can write anything.\\n'\n  + '2. Score 7-10 (hot/SQL) ONLY if at least 2 of these independent signals are present:\\n'\n  + '   - Seniority confirmed by job title (VP, Head of, Director, C-suite, Founder)\\n'\n  + '   - Corporate domain (not gmail/hotmail/yahoo/outlook personal email)\\n'\n  + '   - Website confirms company type and approximate size\\n'\n  + '   - Third-party intelligence found (funding, press, reviews, analyst mentions)\\n'\n  + '3. If message claims budget/urgency but NO corroborating signals exist, cap score at 5.\\n'\n  + '4. Empty or vague message is fine \u2014 rely on the other signals instead.\\n'\n  + '5. A gmail/personal email address with no company website = maximum score 3.\\n'\n  + '6. State WHICH signals drove the score in the reason field \u2014 be specific.\\n\\n'\n  + 'Return ONLY valid JSON (no markdown, no code blocks):\\n'\n  + '{\"score\":<1-10>,\"tier\":\"hot|warm|cold\",\"reason\":\"<one sentence listing the specific signals that determined this score>\",\"email_subject\":\"<subject line>\",\"email_body\":\"<3-4 sentence professional reply>\"}';\n\nconst requestBody = {\n  model: 'claude-opus-4-5',\n  max_tokens: 512,\n  temperature: 0.2,\n  messages: [{ role: 'user', content: prompt }]\n};\n\nreturn {\n  domain,\n  website_text:        websiteText,\n  news_research:       newsText,\n  lead_name:           leadName,\n  lead_email:          leadEmail,\n  lead_company:        leadCompany,\n  lead_job_title:      leadJobTitle,\n  lead_message:        leadMessage,\n  my_icp:              myIcp,\n  hot_threshold:       config.hot_threshold,\n  warm_threshold:      config.warm_threshold,\n  sales_slack_channel: config.sales_slack_channel,\n  requestBody\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "bcef64ae-28d4-49a2-8956-391448c47908",
      "name": "Post Lead to Claude AI",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2496,
        448
      ],
      "parameters": {
        "url": "https://api.anthropic.com/v1/messages",
        "method": "POST",
        "options": {
          "timeout": 60000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "jsonBody": "={{ $json.requestBody }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "117598a2-c64e-43af-aa0c-b97bcef49ef4",
      "name": "Parse Claude AI Score",
      "type": "n8n-nodes-base.code",
      "position": [
        2688,
        448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const text    = $input.item.json.content[0].text;\nconst ai      = JSON.parse(text);\nconst config  = $('Set Lead Scoring Params').first().json;\nconst profile = $('Compile Lead Profile').first().json;\nconst score   = ai.score;\nconst tier    = score >= config.hot_threshold ? 'hot' : score >= config.warm_threshold ? 'warm' : 'cold';\n\nreturn {\n  ai_score:            score,\n  ai_tier:             tier,\n  ai_reason:           ai.reason,\n  ai_email_subject:    ai.email_subject,\n  ai_email_body:       ai.email_body,\n  lead_name:           profile.lead_name,\n  lead_email:          profile.lead_email,\n  lead_company:        profile.lead_company,\n  lead_job_title:      profile.lead_job_title,\n  sales_slack_channel: profile.sales_slack_channel\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "6f4201f4-b05f-43f0-83f3-443bbf4ff365",
      "name": "Upsert Contact in HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        2912,
        448
      ],
      "parameters": {
        "email": "={{ $json.lead_email }}",
        "options": {},
        "authentication": "appToken",
        "additionalFields": {
          "jobTitle": "={{ $json.lead_job_title }}",
          "lastName": "={{ $json.lead_name.split(' ').slice(1).join(' ') }}",
          "firstName": "={{ $json.lead_name.split(' ')[0] }}",
          "companyName": "={{ $json.lead_company }}",
          "lifeCycleStage": "={{ $json.ai_tier === 'hot' ? 'salesqualifiedlead' : $json.ai_tier === 'warm' ? 'marketingqualifiedlead' : 'lead' }}",
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "value": "={{ String($json.ai_score) }}",
                "property": "ai_lead_score"
              },
              {
                "value": "={{ $json.ai_tier }}",
                "property": "ai_lead_tier"
              },
              {
                "value": "={{ $json.ai_reason }}",
                "property": "ai_score_reason"
              }
            ]
          }
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "13d4ea96-4b3b-4e54-86b7-7c7cef6bf855",
      "name": "Enrich Data with HubSpot ID",
      "type": "n8n-nodes-base.set",
      "position": [
        3104,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "en-001",
              "name": "hubspot_vid",
              "type": "number",
              "value": "={{ $json.vid }}"
            },
            {
              "id": "en-002",
              "name": "ai_tier",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.ai_tier }}"
            },
            {
              "id": "en-003",
              "name": "ai_score",
              "type": "number",
              "value": "={{ $('Parse Claude AI Score').item.json.ai_score }}"
            },
            {
              "id": "en-004",
              "name": "ai_reason",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.ai_reason }}"
            },
            {
              "id": "en-005",
              "name": "ai_email_subject",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.ai_email_subject }}"
            },
            {
              "id": "en-006",
              "name": "ai_email_body",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.ai_email_body }}"
            },
            {
              "id": "en-007",
              "name": "lead_name",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.lead_name }}"
            },
            {
              "id": "en-008",
              "name": "lead_email",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.lead_email }}"
            },
            {
              "id": "en-009",
              "name": "lead_company",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.lead_company }}"
            },
            {
              "id": "en-010",
              "name": "sales_slack_channel",
              "type": "string",
              "value": "={{ $('Parse Claude AI Score').item.json.sales_slack_channel }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "86751849-09bc-4dee-a6b8-4e5f009fe1c3",
      "name": "Route Lead by Tier",
      "type": "n8n-nodes-base.switch",
      "position": [
        3328,
        448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Hot",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai_tier }}",
                    "rightValue": "hot"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Warm",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai_tier }}",
                    "rightValue": "warm"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Cold",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai_tier }}",
                    "rightValue": "cold"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "1da7cc4b-eae7-4327-9879-19eabc105e81",
      "name": "Create Deal in HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        3600,
        208
      ],
      "parameters": {
        "stage": "appointmentscheduled",
        "resource": "deal",
        "authentication": "appToken",
        "additionalFields": {
          "dealName": "={{ $json.lead_company + ' \u2014 ' + $json.lead_name + ' (AI Score: ' + $json.ai_score + '/10)' }}",
          "description": "={{ 'AI scored this lead ' + $json.ai_score + '/10. Reason: ' + $json.ai_reason }}"
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8405f6af-612b-40b5-bd76-3f578d7365ef",
      "name": "Notify Sales via Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        3856,
        208
      ],
      "parameters": {
        "text": "={{ '*\ud83d\udd25 Hot lead!*\\n*Name:* ' + $('Enrich Data with HubSpot ID').item.json.lead_name + '\\n*Company:* ' + $('Enrich Data with HubSpot ID').item.json.lead_company + '\\n*AI Score:* ' + $('Enrich Data with HubSpot ID').item.json.ai_score + '/10\\n*Reason:* ' + $('Enrich Data with HubSpot ID').item.json.ai_reason }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Enrich Data with HubSpot ID').item.json.sales_slack_channel }}"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "0498da10-24dd-4923-90ba-b432e4057cb0",
      "name": "Email Hot Lead",
      "type": "n8n-nodes-base.gmail",
      "position": [
        4064,
        208
      ],
      "parameters": {
        "sendTo": "={{ $('Enrich Data with HubSpot ID').item.json.lead_email }}",
        "message": "={{ $('Enrich Data with HubSpot ID').item.json.ai_email_body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $('Enrich Data with HubSpot ID').item.json.ai_email_subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "aea6407c-7dae-43e3-ab52-c51a8c91ec8e",
      "name": "Email Warm Lead",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3600,
        624
      ],
      "parameters": {
        "sendTo": "={{ $json.lead_email }}",
        "message": "={{ $json.ai_email_body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.ai_email_subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "578de774-795e-4d7f-9505-679ad874dded",
      "name": "Email Cold Lead",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3600,
        832
      ],
      "parameters": {
        "sendTo": "={{ $json.lead_email }}",
        "message": "={{ $json.ai_email_body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.ai_email_subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8e6f6a6b-3a2b-4fc3-995c-bd58f8b11fa5",
      "name": "Setup Web Search Params",
      "type": "n8n-nodes-base.code",
      "position": [
        1856,
        448
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const company = $('When Lead Submitted').first().json.body.company || '';\nconst domain  = $('Extract Domain from Email').first().json.domain || '';\nconst content = 'You are a B2B sales researcher. Use web search to build an intelligence brief about this company from THIRD-PARTY sources only.\\n\\n' + 'Company: ' + company + '\\n' + 'Exclude domain: ' + domain + '\\n\\n' + 'Search for the 5 most relevant findings from 2023-2025 covering:\\n' + '1. Funding rounds, investors, valuation, or acquisition news\\n' + '2. Product launches, feature announcements, or major press releases\\n' + '3. Customer wins, partnerships, or market expansion signals\\n' + '4. Executive hires, layoffs, or strategic pivots\\n' + '5. Analyst reports, awards, or competitive intelligence\\n\\n' + 'CRITICAL: Do NOT visit or summarise content from ' + domain + ' (the company own website). ' + 'Focus exclusively on news sites, LinkedIn, TechCrunch, G2, Crunchbase, press release wires, and industry publications.\\n\\n' + 'For each finding: state the exact source name, date (if found), and a 2-3 sentence summary of why it matters for B2B sales qualification. ' + 'If nothing notable is found, say so clearly.';\nreturn { company, domain, requestBody: { model: 'claude-3-5-sonnet-20241022', max_tokens: 2000, tools: [{ type: 'web_search_20250305', name: 'web_search', max_uses: 5 }], messages: [{ role: 'user', content }] } };"
      },
      "typeVersion": 2
    },
    {
      "id": "c0de35d0-ef12-4609-9a9e-13b676790f2c",
      "name": "Post to Company News API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2064,
        448
      ],
      "parameters": {
        "url": "https://api.anthropic.com/v1/messages",
        "method": "POST",
        "options": {
          "timeout": 60000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "jsonBody": "={{ $json.requestBody }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            },
            {
              "name": "anthropic-beta",
              "value": "web-search-2025-03-05"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "8613c4f3-1320-4f03-bac3-61a9d24fc29b",
  "connections": {
    "Route Lead by Tier": {
      "main": [
        [
          {
            "node": "Create Deal in HubSpot",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email Warm Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email Cold Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Company Website": {
      "main": [
        [
          {
            "node": "Setup Web Search Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Lead Submitted": {
      "main": [
        [
          {
            "node": "Post Lead Score Property",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compile Lead Profile": {
      "main": [
        [
          {
            "node": "Post Lead to Claude AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Claude AI Score": {
      "main": [
        [
          {
            "node": "Upsert Contact in HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Deal in HubSpot": {
      "main": [
        [
          {
            "node": "Notify Sales via Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Sales via Slack": {
      "main": [
        [
          {
            "node": "Email Hot Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Lead to Claude AI": {
      "main": [
        [
          {
            "node": "Parse Claude AI Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Lead Tier Property": {
      "main": [
        [
          {
            "node": "Post Score Reason Property",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Lead Scoring Params": {
      "main": [
        [
          {
            "node": "Extract Domain from Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup Web Search Params": {
      "main": [
        [
          {
            "node": "Post to Company News API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Lead Score Property": {
      "main": [
        [
          {
            "node": "Post Lead Tier Property",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Company News API": {
      "main": [
        [
          {
            "node": "Compile Lead Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Domain from Email": {
      "main": [
        [
          {
            "node": "Get Company Website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Contact in HubSpot": {
      "main": [
        [
          {
            "node": "Enrich Data with HubSpot ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Score Reason Property": {
      "main": [
        [
          {
            "node": "Set Lead Scoring Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich Data with HubSpot ID": {
      "main": [
        [
          {
            "node": "Route Lead by Tier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}