Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ansh808s/0d16cb5a6c92bdc546bc80b82dc64a78 to your computer and use it in GitHub Desktop.

Select an option

Save ansh808s/0d16cb5a6c92bdc546bc80b82dc64a78 to your computer and use it in GitHub Desktop.
Intent-Based Lead Scoring with Enrichment
{
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "form-submission",
"options": {}
},
"id": "9ea65e01-3766-4996-907c-ae16a0be6fe5",
"name": "Form Submission Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-7792,
1376
],
"webhookId": "c6ed79f7-b103-4af4-a565-2d4ee5458c67"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "email",
"value": "={{ $json.body.email }}",
"type": "string"
},
{
"id": "id-4",
"name": "formType",
"value": "={{ $json.body.formType }}",
"type": "string"
},
{
"id": "id-5",
"name": "pagesVisited",
"value": "={{ $json.body.pagesVisited }}",
"type": "array"
},
{
"id": "id-6",
"name": "timeOnSite",
"value": "={{ $json.body.timeOnSite }}",
"type": "number"
},
{
"id": "id-7",
"name": "sessions",
"value": "={{ $json.body.sessions }}",
"type": "number"
}
]
},
"options": {}
},
"id": "2d0ac364-43db-4f26-a3c7-38f21fdbd94a",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-7568,
1376
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.limadata.com/api/v1/enrich/person",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "x-api-key",
"value": "LIMADATA_API"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"email\": \"={{ $('Workflow Configuration').item.json.email }}\"\n}",
"options": {}
},
"id": "f6b237db-6ed0-48ea-b505-261b87cdb32a",
"name": "Limadata Enrichment",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-6896,
1376
]
},
{
"parameters": {
"jsCode": "const items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n let score = 0;\n \n // Get behavioral data from Workflow Configuration node\n const workflowData = $('Workflow Configuration').first().json;\n const pagesVisited = workflowData.pagesVisited || [];\n const timeOnSite = workflowData.timeOnSite || 0;\n const sessions = workflowData.sessions || 1;\n const formType = workflowData.formType || '';\n \n // Pages visited scoring (max 30 points)\n score += Math.min(pagesVisited.length * 3, 30);\n \n // Time on site scoring (max 20 points)\n score += Math.min(Math.floor(timeOnSite / 60), 20);\n \n // Session frequency (max 15 points)\n score += Math.min(sessions * 5, 15);\n \n // Form type scoring (max 20 points)\n if (formType === 'demo') score += 20;\n else if (formType === 'pricing') score += 15;\n else if (formType === 'content') score += 10;\n else if (formType === 'newsletter') score += 5;\n \n // Enrichment data scoring (max 15 points)\n const seniority = item.json?.person?.employment?.seniority || '';\n const companySize = item.json?.company?.employees?.employee_count || 0;\n \n let seniorityScore = 0;\n if (seniority.match(/owner|partner|founder|ceo|cto|cfo|chief/i)) seniorityScore = 10;\n else if (seniority.match(/director|vp|head/i)) seniorityScore = 7;\n else if (seniority.match(/manager|lead/i)) seniorityScore = 5;\n \n let companySizeScore = 0;\n if (companySize > 500) companySizeScore = 5;\n else if (companySize > 100) companySizeScore = 3;\n else if (companySize > 50) companySizeScore = 1;\n \n score += seniorityScore + companySizeScore;\n results.push({\n json: {\n ...item.json,\n email: workflowData.email,\n name: item.json?.person?.name || 'Unknown',\n company: item.json?.company?.name || item.json?.person?.employment?.company_name || 'Unknown',\n jobTitle: item.json?.person?.employment?.title || 'Unknown',\n linkedinUrl: item.json?.person?.linkedin?.url || '',\n companyWebsite: item.json?.company?.website || '',\n seniority: seniority,\n companySize: companySize,\n industry: item.json?.company?.categories?.industry || '',\n intentScore: Math.min(score, 100),\n scoringBreakdown: {\n pages: Math.min(pagesVisited.length * 3, 30),\n time: Math.min(Math.floor(timeOnSite / 60), 20),\n sessions: Math.min(sessions * 5, 15),\n formType: formType === 'demo' ? 20 : formType === 'pricing' ? 15 : formType === 'content' ? 10 : 5,\n enrichment: seniorityScore + companySizeScore\n }\n }\n });\n}\n\nreturn results;"
},
"id": "4641fd0f-c773-4dd4-a322-f158dace898f",
"name": "Calculate Intent Score",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-6672,
1376
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"leftValue": "={{ $json.intentScore }}",
"rightValue": 75,
"operator": {
"type": "number",
"operation": "gte"
},
"id": "2dc19dc0-8953-4936-b337-eb5dc4aeede7"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "High Intent (75+)"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"leftValue": "={{ $json.intentScore }}",
"rightValue": 40,
"operator": {
"type": "number",
"operation": "gte"
},
"id": "ed3ccb87-d07e-4f0a-b958-b0fc94ddcce5"
},
{
"leftValue": "={{ $json.intentScore }}",
"rightValue": 75,
"operator": {
"type": "number",
"operation": "lt"
},
"id": "2344b598-c5a8-4c8e-af9c-5bc71d8b2d8b"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Medium Intent (40-74)"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"leftValue": "={{ $json.intentScore }}",
"rightValue": 40,
"operator": {
"type": "number",
"operation": "lt"
},
"id": "57737dd6-38b6-4797-9286-f94e02fdbead"
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "Low Intent (<40)"
}
]
},
"options": {}
},
"id": "bb666110-bde7-461f-b0de-4c19eb81d54c",
"name": "Route by Intent Score",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.4,
"position": [
-6448,
1360
]
},
{
"parameters": {
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "SLACK_CHANNEL_ID"
},
"text": "=*HIGH INTENT LEAD ALERT*\n\n👤 *{{ $json.name }}*\n📧 {{ $json.email }}\n🏢 {{ $json.company }}\n💼 {{ $json.jobTitle }}\n📊 Intent Score: *{{ $json.intentScore }}/100*\n\n*Scoring Breakdown:*\n• Pages Visited: {{ $json.scoringBreakdown.pages }} pts\n• Time on Site: {{ $json.scoringBreakdown.time }} pts\n• Sessions: {{ $json.scoringBreakdown.sessions }} pts\n• Form Type: {{ $json.scoringBreakdown.formType }} pts\n• Enrichment: {{ $json.scoringBreakdown.enrichment }} pts\n\n*Action Required:* Reach out within 2 hours\nLinkedIn: {{ $json.linkedinUrl }}",
"otherOptions": {}
},
"id": "57596709-be34-4c5d-a6a2-caa64e56155e",
"name": "Alert SDR via Slack",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.4,
"position": [
-6224,
992
],
"webhookId": "495d88c9-d129-4f41-a94d-f8e1ec9c97a8"
},
{
"parameters": {
"authentication": "oAuth2",
"email": "={{ $json.email }}",
"additionalFields": {
"companyName": "={{ $json.company }}",
"customPropertiesUi": {
"customPropertiesValues": [
{
"property": "lead_score",
"value": "={{ $json.intentScore }}"
},
{
"property": "lead_stage",
"value": "Sales Ready"
},
{
"property": "seniority",
"value": "={{ $json.seniority }}"
},
{
"property": "company_size",
"value": "={{ $json.companySize }}"
},
{
"property": "industry",
"value": "={{ $json.industry }}"
}
]
},
"firstName": "={{ $json.name ? $json.name.split(' ')[0] : '' }}",
"jobTitle": "={{ $json.jobTitle }}",
"lastName": "={{ $json.name ? $json.name.split(' ').slice(1).join(' ') : '' }}",
"linkedinUrl": "={{ $json.linkedinUrl }}",
"websiteUrl": "={{ $json.companyWebsite }}"
},
"options": {}
},
"id": "8cfe9d4b-c0f4-48cf-8655-e0ad63e31fb5",
"name": "Create HubSpot Contact - High Intent",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 2.2,
"position": [
-6224,
1184
],
"credentials": {
"hubspotOAuth2Api": {
"id": "HUBSPOT_ID",
"name": "HubSpot account"
}
}
},
{
"parameters": {
"resource": "lead",
"campaignId": "LEMLIST_CAMPAIGN_ID",
"email": "={{ $json.email }}",
"additionalFields": {
"companyName": "={{ $json.company }}",
"firstName": "={{ $json.name ? $json.name.split(' ')[0] : '' }}",
"lastName": "={{ $json.name ? $json.name.split(' ').slice(1).join(' ') : '' }}"
}
},
"id": "b39ec58d-6fa3-4e95-b626-7fd79a5a0f22",
"name": "Send Personalized SDR Email",
"type": "n8n-nodes-base.lemlist",
"typeVersion": 2,
"position": [
-6000,
1184
]
},
{
"parameters": {
"authentication": "oAuth2",
"email": "={{ $json.email }}",
"additionalFields": {
"companyName": "={{ $json.company }}",
"customPropertiesUi": {
"customPropertiesValues": [
{
"property": "lead_score",
"value": "={{ $json.intentScore }}"
},
{
"property": "lead_stage",
"value": "MQL"
},
{
"property": "seniority",
"value": "={{ $json.seniority }}"
},
{
"property": "company_size",
"value": "={{ $json.companySize }}"
}
]
},
"firstName": "={{ $json.name ? $json.name.split(' ')[0] : '' }}",
"jobTitle": "={{ $json.jobTitle }}",
"lastName": "={{ $json.name ? $json.name.split(' ').slice(1).join(' ') : '' }}",
"linkedinUrl": "={{ $json.linkedinUrl }}"
},
"options": {}
},
"id": "d1f6413a-c9ef-4122-aa93-2fa196ac5614",
"name": "Create HubSpot Contact - Medium Intent",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 2.2,
"position": [
-6224,
1472
],
"credentials": {
"hubspotOAuth2Api": {
"id": "HUBSPOT_ID",
"name": "HubSpot account"
}
}
},
{
"parameters": {
"resource": "lead",
"campaignId": "LEMLIST_CAMPAIGN_ID",
"email": "={{ $json.email }}",
"additionalFields": {
"companyName": "={{ $json.company }}",
"firstName": "={{ $json.name ? $json.name.split(' ')[0] : '' }}",
"lastName": "={{ $json.name ? $json.name.split(' ').slice(1).join(' ') : '' }}"
}
},
"id": "cc7e6679-385b-41f5-b285-8bbb7651d73d",
"name": "Add to Weekly Content Digest",
"type": "n8n-nodes-base.lemlist",
"typeVersion": 2,
"position": [
-6000,
1568
]
},
{
"parameters": {
"authentication": "oAuth2",
"email": "={{ $json.email }}",
"additionalFields": {
"companyName": "={{ $json.company }}",
"customPropertiesUi": {
"customPropertiesValues": [
{
"property": "lead_score",
"value": "={{ $json.intentScore }}"
},
{
"property": "lead_stage",
"value": "Nurture"
},
{
"property": "seniority",
"value": "={{ $json.seniority }}"
},
{
"property": "company_size",
"value": "={{ $json.companySize }}"
}
]
},
"firstName": "={{ $json.name ? $json.name.split(' ')[0] : '' }}",
"jobTitle": "={{ $json.jobTitle }}",
"lastName": "={{ $json.name ? $json.name.split(' ').slice(1).join(' ') : '' }}",
"linkedinUrl": "={{ $json.linkedinUrl }}"
},
"options": {}
},
"id": "82d9a79c-6045-4c1a-b08f-d9faa3711ed2",
"name": "Create HubSpot Contact - Low Intent",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 2.2,
"position": [
-6224,
1760
],
"credentials": {
"hubspotOAuth2Api": {
"id": "HUBSPOT_ID",
"name": "HubSpot account"
}
}
},
{
"parameters": {
"authentication": "oAuth2",
"operation": "search",
"limit": 1,
"filterGroupsUi": {
"filterGroupsValues": [
{
"filtersUi": {
"filterValues": [
{
"propertyName": "email|string",
"value": "={{ $json.email }}"
}
]
}
}
]
},
"additionalFields": {}
},
"id": "126d2efb-5e8a-46a2-a774-1d95cc5403a5",
"name": "Check for Duplicates in HubSpot",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 2.2,
"position": [
-7344,
1376
],
"alwaysOutputData": true,
"credentials": {
"hubspotOAuth2Api": {
"id": "HUBSPOT_ID",
"name": "HubSpot account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://api.limadata.com/api/v1/watch",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "x-api-key",
"value": "LIMADATA_API"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"name\": \"Medium Intent Lead Watch\",\n \"type\": \"PersonJobChanges\",\n \"notification_url\": \"https://your.app.n8n.cloud/webhook/job-change-medium\",\n \"frequency_days\": 7,\n \"settings\": {\n \"people_urls\": [{{ $json.linkedinUrl }}]\n },\n \"external_id\": {{ $json.email }}\n}",
"options": {}
},
"id": "a6af3902-ab48-45cd-9245-76c24549755b",
"name": "Setup Limadata Person Watch - Medium Intent",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-6000,
1376
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.limadata.com/api/v1/watch",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "x-api-key",
"value": "LIMADATA_API"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"name\": \"Low Intent Lead Watch\",\n \"type\": \"PersonJobChanges\",\n \"notification_url\": \"https://yourapp.app.n8n.cloud/webhook/job-change-low\",\n \"frequency_days\": 30,\n \"settings\": {\n \"people_urls\": [{{ $json.linkedinUrl }}]\n },\n \"external_id\": {{ $json.email }}\n}",
"options": {}
},
"id": "4e8bf0ec-4578-4dd0-a9a6-a28625aaada0",
"name": "Setup Limadata Person Watch - Low Intent",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-6000,
1760
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "id-1",
"leftValue": "={{ $json.id }}",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "1cf94326-2946-474c-9182-6e11ea9f272c",
"name": "Stop if Duplicate Found",
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
-7120,
1376
]
}
],
"connections": {
"Form Submission Webhook": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "Check for Duplicates in HubSpot",
"type": "main",
"index": 0
}
]
]
},
"Limadata Enrichment": {
"main": [
[
{
"node": "Calculate Intent Score",
"type": "main",
"index": 0
}
]
]
},
"Calculate Intent Score": {
"main": [
[
{
"node": "Route by Intent Score",
"type": "main",
"index": 0
}
]
]
},
"Route by Intent Score": {
"main": [
[
{
"node": "Alert SDR via Slack",
"type": "main",
"index": 0
},
{
"node": "Create HubSpot Contact - High Intent",
"type": "main",
"index": 0
}
],
[
{
"node": "Create HubSpot Contact - Medium Intent",
"type": "main",
"index": 0
}
],
[
{
"node": "Create HubSpot Contact - Low Intent",
"type": "main",
"index": 0
}
]
]
},
"Create HubSpot Contact - High Intent": {
"main": [
[
{
"node": "Send Personalized SDR Email",
"type": "main",
"index": 0
}
]
]
},
"Create HubSpot Contact - Medium Intent": {
"main": [
[
{
"node": "Setup Limadata Person Watch - Medium Intent",
"type": "main",
"index": 0
},
{
"node": "Add to Weekly Content Digest",
"type": "main",
"index": 0
}
]
]
},
"Create HubSpot Contact - Low Intent": {
"main": [
[
{
"node": "Setup Limadata Person Watch - Low Intent",
"type": "main",
"index": 0
}
]
]
},
"Check for Duplicates in HubSpot": {
"main": [
[
{
"node": "Stop if Duplicate Found",
"type": "main",
"index": 0
}
]
]
},
"Stop if Duplicate Found": {
"main": [
[
{
"node": "Limadata Enrichment",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "5544243018978d8bc3747384ecd8168b71d951ca320a4w5a19d103243b3c5f6c"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment