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-powered lead scoring with demographic, behavioral, and engagement factors4---56# AI Lead Scoring78Scores leads based on weighted factors and provides classification with action recommendations.910## Scoring Weights11- Demographics: 30% (company size, industry, title, tech stack)12- Behavior: 50% (website visits, email engagement, form submissions, webinar attendance)13- Engagement: 20% (time on site, return visits, content depth, pricing page views)1415## Thresholds16- HOT: 80+ (immediate sales follow-up)17- WARM: 60-79 (nurture + sales touch)18- COOL: 40-59 (marketing automation)19- COLD: <40 (re-engage or disqualify)2021## Score Decay22- -5 points per week of inactivity2324## Usage25```typescript26import { AILeadScoring } from './lib/ai-lead-scoring';2728const scorer = new AILeadScoring();29const result = scorer.scoreLead({30 id: 'lead-123',31 employees: 150,32 industry: 'SaaS',33 title: 'VP of Engineering',34 uses_target_tech: true,35 activities: {36 website_visits: 5,37 email_opens: 3,38 email_clicks: 2,39 form_submissions: 140 },41 engagement: {42 avg_time_on_site: 180,43 return_visits: 3,44 unique_pages: 8,45 viewed_pricing: true46 },47 last_activity_date: new Date()48});49// Result: { score: 72.5, classification: 'WARM', recommendation: 'Nurture sequence + sales touch' }50```5152## CRM Integration (HubSpot)53```typescript54async function updateHubSpotScore(contactId: string, score: number, classification: string) {55 await fetch(`https://api.hubapi.com/crm/v3/objects/contacts/${contactId}`, {56 method: 'PATCH',57 headers: {58 'Authorization': `Bearer ${process.env.HUBSPOT_API_KEY}`,59 'Content-Type': 'application/json'60 },61 body: JSON.stringify({62 properties: {63 lead_score: score,64 lead_classification: classification,65 last_scored: new Date().toISOString()66 }67 })68 });69}70```7172## Webhook Endpoint73```typescript74app.post('/webhook/lead-activity', async (req, res) => {75 const { lead_id } = req.body;76 const leadData = await crm.getLead(lead_id);77 const result = scorer.scoreLead(leadData);78 await crm.updateLeadScore(lead_id, result.score, result.classification);79 if (result.classification === 'HOT') await notifySalesTeam(lead_id, result.score);80 res.json({ status: 'success', ...result });81});82```8384## Deployment Checklist851. Set env vars: CRM_API_KEY, CRM_INSTANCE_URL, WEBHOOK_SECRET862. Deploy to AWS Lambda, Google Cloud Functions, or Vercel873. Create CRM custom fields: lead_score, lead_classification, last_scored884. Configure webhook triggers for lead activities895. Set up automated workflows by score tier906. Monitor scoring accuracy weekly917. Adjust weights based on conversion data