AI Lead Scoring
Scores leads based on weighted factors and provides classification with action recommendations.
Scoring Weights
- Demographics: 30% (company size, industry, title, tech stack)
- Behavior: 50% (website visits, email engagement, form submissions, webinar attendance)
- Engagement: 20% (time on site, return visits, content depth, pricing page views)
Thresholds
- HOT: 80+ (immediate sales follow-up)
- WARM: 60-79 (nurture + sales touch)
- COOL: 40-59 (marketing automation)
- COLD: <40 (re-engage or disqualify)
Score Decay
- -5 points per week of inactivity
Usage
import { AILeadScoring } from './lib/ai-lead-scoring';
const scorer = new AILeadScoring();
const result = scorer.scoreLead({
id: 'lead-123',
employees: 150,
industry: 'SaaS',
title: 'VP of Engineering',
uses_target_tech: true,
activities: {
website_visits: 5,
email_opens: 3,
email_clicks: 2,
form_submissions: 1
},
engagement: {
avg_time_on_site: 180,
return_visits: 3,
unique_pages: 8,
viewed_pricing: true
},
last_activity_date: new Date()
});
// Result: { score: 72.5, classification: 'WARM', recommendation: 'Nurture sequence + sales touch' }
CRM Integration (HubSpot)
async function updateHubSpotScore(contactId: string, score: number, classification: string) {
await fetch(`https://api.hubapi.com/crm/v3/objects/contacts/${contactId}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.HUBSPOT_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
properties: {
lead_score: score,
lead_classification: classification,
last_scored: new Date().toISOString()
}
})
});
}
Webhook Endpoint
app.post('/webhook/lead-activity', async (req, res) => {
const { lead_id } = req.body;
const leadData = await crm.getLead(lead_id);
const result = scorer.scoreLead(leadData);
await crm.updateLeadScore(lead_id, result.score, result.classification);
if (result.classification === 'HOT') await notifySalesTeam(lead_id, result.score);
res.json({ status: 'success', ...result });
});
Deployment Checklist
- Set env vars: CRM_API_KEY, CRM_INSTANCE_URL, WEBHOOK_SECRET
- Deploy to AWS Lambda, Google Cloud Functions, or Vercel
- Create CRM custom fields: lead_score, lead_classification, last_scored
- Configure webhook triggers for lead activities
- Set up automated workflows by score tier
- Monitor scoring accuracy weekly
- Adjust weights based on conversion data
1---2name: ai-lead-scoring3description: AI Lead Scoring4---5# AI Lead Scoring67Scores leads based on weighted factors and provides classification with action recommendations.89## Scoring Weights10- Demographics: 30% (company size, industry, title, tech stack)11- Behavior: 50% (website visits, email engagement, form submissions, webinar attendance)12- Engagement: 20% (time on site, return visits, content depth, pricing page views)1314## Thresholds15- HOT: 80+ (immediate sales follow-up)16- WARM: 60-79 (nurture + sales touch)17- COOL: 40-59 (marketing automation)18- COLD: <40 (re-engage or disqualify)1920## Score Decay21- -5 points per week of inactivity2223## Usage24```typescript25import { AILeadScoring } from './lib/ai-lead-scoring';2627const scorer = new AILeadScoring();28const result = scorer.scoreLead({29 id: 'lead-123',30 employees: 150,31 industry: 'SaaS',32 title: 'VP of Engineering',33 uses_target_tech: true,34 activities: {35 website_visits: 5,36 email_opens: 3,37 email_clicks: 2,38 form_submissions: 139 },40 engagement: {41 avg_time_on_site: 180,42 return_visits: 3,43 unique_pages: 8,44 viewed_pricing: true45 },46 last_activity_date: new Date()47});48// Result: { score: 72.5, classification: 'WARM', recommendation: 'Nurture sequence + sales touch' }49```5051## CRM Integration (HubSpot)52```typescript53async function updateHubSpotScore(contactId: string, score: number, classification: string) {54 await fetch(`https://api.hubapi.com/crm/v3/objects/contacts/${contactId}`, {55 method: 'PATCH',56 headers: {57 'Authorization': `Bearer ${process.env.HUBSPOT_API_KEY}`,58 'Content-Type': 'application/json'59 },60 body: JSON.stringify({61 properties: {62 lead_score: score,63 lead_classification: classification,64 last_scored: new Date().toISOString()65 }66 })67 });68}69```7071## Webhook Endpoint72```typescript73app.post('/webhook/lead-activity', async (req, res) => {74 const { lead_id } = req.body;75 const leadData = await crm.getLead(lead_id);76 const result = scorer.scoreLead(leadData);77 await crm.updateLeadScore(lead_id, result.score, result.classification);78 if (result.classification === 'HOT') await notifySalesTeam(lead_id, result.score);79 res.json({ status: 'success', ...result });80});81```8283## Deployment Checklist841. Set env vars: CRM_API_KEY, CRM_INSTANCE_URL, WEBHOOK_SECRET852. Deploy to AWS Lambda, Google Cloud Functions, or Vercel863. Create CRM custom fields: lead_score, lead_classification, last_scored874. Configure webhook triggers for lead activities885. Set up automated workflows by score tier896. Monitor scoring accuracy weekly907. Adjust weights based on conversion data