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 factors4target: https://tasking.tech5---67# AI Lead Scoring89Scores leads based on weighted factors and provides classification with action recommendations.1011## Scoring Weights12- Demographics: 30% (company size, industry, title, tech stack)13- Behavior: 50% (website visits, email engagement, form submissions, webinar attendance)14- Engagement: 20% (time on site, return visits, content depth, pricing page views)1516## Thresholds17- HOT: 80+ (immediate sales follow-up)18- WARM: 60-79 (nurture + sales touch)19- COOL: 40-59 (marketing automation)20- COLD: <40 (re-engage or disqualify)2122## Score Decay23- -5 points per week of inactivity2425## Usage26```typescript27import { AILeadScoring } from './lib/ai-lead-scoring';2829const scorer = new AILeadScoring();30const result = scorer.scoreLead({31 id: 'lead-123',32 employees: 150,33 industry: 'SaaS',34 title: 'VP of Engineering',35 uses_target_tech: true,36 activities: {37 website_visits: 5,38 email_opens: 3,39 email_clicks: 2,40 form_submissions: 141 },42 engagement: {43 avg_time_on_site: 180,44 return_visits: 3,45 unique_pages: 8,46 viewed_pricing: true47 },48 last_activity_date: new Date()49});50// Result: { score: 72.5, classification: 'WARM', recommendation: 'Nurture sequence + sales touch' }51```5253## CRM Integration (HubSpot)54```typescript55async function updateHubSpotScore(contactId: string, score: number, classification: string) {56 await fetch(`https://api.hubapi.com/crm/v3/objects/contacts/${contactId}`, {57 method: 'PATCH',58 headers: {59 'Authorization': `Bearer ${process.env.HUBSPOT_API_KEY}`,60 'Content-Type': 'application/json'61 },62 body: JSON.stringify({63 properties: {64 lead_score: score,65 lead_classification: classification,66 last_scored: new Date().toISOString()67 }68 })69 });70}71```7273## Webhook Endpoint74```typescript75app.post('/webhook/lead-activity', async (req, res) => {76 const { lead_id } = req.body;77 const leadData = await crm.getLead(lead_id);78 const result = scorer.scoreLead(leadData);79 await crm.updateLeadScore(lead_id, result.score, result.classification);80 if (result.classification === 'HOT') await notifySalesTeam(lead_id, result.score);81 res.json({ status: 'success', ...result });82});83```8485## Deployment Checklist861. Set env vars: CRM_API_KEY, CRM_INSTANCE_URL, WEBHOOK_SECRET872. Deploy to AWS Lambda, Google Cloud Functions, or Vercel883. Create CRM custom fields: lead_score, lead_classification, last_scored894. Configure webhook triggers for lead activities905. Set up automated workflows by score tier916. Monitor scoring accuracy weekly927. Adjust weights based on conversion data