Score inbound leads 0–100 using firmographic and behavioral signals, then automatically route them to the correct HubSpot pipeline stage (Hot / Warm / Cold / Disqualified).
Built with Python + HubSpot Contacts API. Designed as a lightweight, portable scoring engine that works with a CSV export or live HubSpot data.
- Reads leads from a CSV file or fetches live contacts from the HubSpot CRM API
- Scores each lead 0–100 using a weighted model (see table below)
- Maps the score to a pipeline stage
- Optionally pushes
lead_scoreandpipeline_stageback to HubSpot contact properties - Outputs a
routing_report.csvwith full score breakdown
| Signal | Max Points | Logic |
|---|---|---|
| Company size (employees) | 25 | 500+ = 25, 200–499 = 20, 50–199 = 15, 10–49 = 8, 1–9 = 3 |
| Industry match (ICP list) | 20 | Full ICP match = 20, Partial match = 10, No match = 0 |
| Job title seniority | 20 | C-suite/Founder = 20, VP = 15, Director/Head = 10, Manager/Lead = 5 |
| Has phone number | 5 | Present = 5, Missing = 0 |
| Has LinkedIn URL | 5 | Present = 5, Missing = 0 |
| Country/region match | 10 | ICP country = 10, Partial = 5, No match = 0 |
| Recent HubSpot activity | 15 | < 7 days = 15, 7–30 days = 7, > 30 days = 0 |
| Total | 100 |
| Score Range | Stage |
|---|---|
| 76 – 100 | 🔥 Hot |
| 51 – 75 | ♨️ Warm |
| 31 – 50 | ❄️ Cold |
| 0 – 30 | ✗ Disqualified |
git clone https://github.com/stevenkaranja/crm-lead-router.git
cd crm-lead-router
pip install -r requirements.txtcp .env.example .env
# Edit .env and add your HubSpot Private App tokenTo create a HubSpot Private App token: HubSpot → Settings → Integrations → Private Apps → Create. Required scopes: crm.objects.contacts.read, crm.objects.contacts.write.
Edit config.py to update:
ICP_INDUSTRIES— your target industriesICP_COUNTRIES— your target countries/regionsSENIORITY_MAP— title keywords and their point values
python lead_router.py --source csv --csv-file sample_leads.csvpython lead_router.py --source hubspot --limit 200python lead_router.py --source hubspot --update-hubspotpython lead_router.py --source csv --csv-file leads.csv --output my_report.csvusage: lead_router.py [-h] [--source {csv,hubspot}] [--csv-file CSV_FILE]
[--output OUTPUT] [--update-hubspot] [--limit LIMIT]
--source Lead source: 'csv' (default) or 'hubspot'
--csv-file Path to input CSV (default: sample_leads.csv)
--output Output report path (default: routing_report.csv)
--update-hubspot Push lead_score + pipeline_stage to HubSpot contacts
--limit Max contacts to fetch from HubSpot (default: 100)
Required columns for --source csv:
first_name, last_name, email, company, job_title, industry,
employee_count, country, phone, linkedin_url
See sample_leads.csv for a 10-row example with realistic African and global B2B leads.
=============================================
LEAD ROUTING SUMMARY — 10 leads processed
=============================================
Hot 3 ( 30.0%) ██████
Warm 4 ( 40.0%) ████████
Cold 2 ( 20.0%) ████
Disqualified 1 ( 10.0%) ██
=============================================
| Column | Description |
|---|---|
lead_score |
Total score 0–100 |
pipeline_stage |
Hot / Warm / Cold / Disqualified |
score_company_size |
Points from employee count |
score_industry |
Points from industry ICP match |
score_job_title |
Points from seniority |
score_phone |
Points for phone presence |
score_linkedin |
Points for LinkedIn presence |
score_country |
Points from country ICP match |
score_recent_activity |
Points from HubSpot activity recency |
When using --update-hubspot, ensure these custom contact properties exist in your HubSpot portal:
| Property Name | Type | Description |
|---|---|---|
lead_score |
Number | Computed 0–100 score |
pipeline_stage |
Single-line text | Hot / Warm / Cold / Disqualified |
Create them via: HubSpot → Settings → Properties → Create property.
crm-lead-router/
├── lead_router.py # Main scoring + routing script
├── config.py # ICP config: industries, countries, seniority map
├── sample_leads.csv # 10 sample leads for testing
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
└── README.md
- Python 3.10+
- pandas — CSV I/O and data manipulation
- requests — HubSpot REST API calls
- python-dotenv — Environment variable management