
AI Lead Qualification & Sales Routing Agent
Automate lead scoring, enrich company insights, and route high-intent prospects to the right sales team with AI-powered intelligence for faster decisions and improved conversion rates.
Custom SaaS Platforms- OpenAI
- n8n
- Node.js
- Express
- Slack
- Airtable
- Clearbit
Project Overview
The AI Lead Qualification & Sales Routing Agent is an automated system that evaluates inbound leads, enriches company information, and routes prospects based on their likelihood of converting. Powered by GPT-4.1 and n8n, it scores leads across budget, urgency, purchase intent, ICP match, and email quality. The system classifies leads as HOT, WARM, or COLD and directs them to the appropriate sales follow-up channel through Slack alerts, email nurturing, and Airtable CRM integration.

Business Problem
Sales teams receive inbound leads from multiple sources but often lack a consistent, automated process to qualify prospects and prioritize follow-ups. This creates several challenges:
- Inconsistent Lead Scoring: Qualification decisions depend on who reviews the form first, resulting in missed opportunities and wasted sales representative time.
- Delayed Response to Hot Leads: High-intent prospects, such as those with approved budgets and urgent timelines, may wait hours before receiving a response.
- Manual Company Research: Sales representatives spend valuable time researching companies behind email addresses before deciding whether a lead is worth pursuing.
- Lack of Tiered Routing: Without automated escalation, urgent prospects and leads requiring long-term nurturing are handled without clear prioritization.
- Fragmented Lead History: Repeat submissions from the same email address are recorded separately, making it difficult to maintain a complete interaction history.
Proposed Solution:
The solution is an AI-powered lead qualification and sales routing system that automates the process from lead submission to sales follow-up. It validates incoming lead data, detects duplicate submissions, and enriches company information using Clearbit. GPT-4.1 evaluates each lead across five qualification dimensions: budget, urgency, purchase intent, Ideal Customer Profile (ICP) match, and email quality, generating a score from 0–100.
Based on the score, the system classifies leads into three categories: HOT (80–100), WARM (50–79), and COLD (0–49). HOT leads trigger real-time Slack notifications, WARM leads are directed to the nurturing process, and COLD leads are archived. Airtable stores the qualified lead information, while a rule-based fallback scoring mechanism maintains basic qualification functionality if the AI service becomes unavailable.
The system also provides a dashboard for monitoring lead volume, qualification categories, average scores, conversion metrics, and lead sources. Security controls, including rate limiting, request validation, and error handling, help support reliable processing.
End-to-End Workflow
Lead Intake
- Multiple Input Channels: Accepts leads through a hosted landing page form, direct REST API requests, embedded form webhooks, and n8n-triggered workflows.
- Input Validation: Validates required fields, including name and email, before processing begins.
- Data Normalization: Normalizes incoming lead data to maintain consistent formatting.
- Duplicate Detection: Identifies repeat submissions using the email address and updates existing records instead of creating duplicates.
- Lead Source Tracking: Records the source channel for each lead to support tracking and reporting.
- Automated Processing: Uses a Node.js Express server and n8n workflows to coordinate lead intake and subsequent processing
AI scoring engine
- Each lead is analysed by GPT-4.1 across five dimensions: budget signals, urgency language, purchase intent, ICP (Ideal Customer Profile) match, and email quality
- Returns a structured score from 0–100 and classifies the lead as HOT, WARM, or COLD
- Produces a 12-field analysis object: score, category, intent, budget, urgency, ICP match, AI summary, recommended action, key signals, risk factors, estimated deal size, and sales rep assignment
- Falls back to a rule-based keyword scoring engine if the OpenAI API is unavailable, guaranteeing zero-downtime operation
Enrichment layer
- Extracts the company domain from the lead’s email address and enriches it with external company intelligence
- With Clearbit: pulls company name, industry, employee count, estimated revenue, tech stack, LinkedIn URL, and headquarters location
- Without Clearbit: performs basic domain analysis, infers company name, identifies TLD-based region, and confirms it is a business (not free) email
- Free email providers (Gmail, Yahoo, Hotmail, etc.) are skipped for enrichment and flagged accordingly
Alerting and routing
- Fires Slack alerts for every HOT lead: rich Block Kit messages, including all 12 analysis fields, AI summary, estimated deal size, and assigned sales team
- Routes WARM leads to a nurture queue for email sequence follow-up
- Archives COLD leads automatically with no sales action triggered
- All notification steps run asynchronously, so they never delay the API response back to the form or caller
CRM integration
- Pushes every processed lead to Airtable with 18 mapped fields, including all analysis outputs
- Designed to be swapped for HubSpot or any other CRM with a single service file change
- Skips gracefully if CRM credentials are not configured: the pipeline continues without interruption
How the System Works
The system processes each incoming lead through a sequence of automated steps:
- Lead Intake: Receives lead information from website forms, API submissions, and n8n webhooks.
- Data Validation: Validates incoming information, normalizes fields, and checks for duplicate email addresses. Repeat submissions are added to the existing lead history.
- Company Enrichment: Uses Clearbit to retrieve company details, such as industry, employee count, estimated revenue, and technology stack. If enrichment is unavailable, the system uses domain-based analysis where possible.
- AI-Powered Qualification: GPT-4.1 evaluates the lead based on budget, urgency, purchase intent, ICP match, and email quality. It generates a score from 0–100, a classification, a summary, key signals, risks, and recommended actions.
- Lead Classification: Assigns each lead to a category: HOT (80–100), WARM (50–79), or COLD (0–49).
- Automated Routing: Sends HOT leads to Slack for immediate attention, directs WARM leads to nurturing, and archives COLD leads.
- CRM and Dashboard Updates: Stores lead information in Airtable and updates the dashboard with qualification scores, lead categories, volume, and other performance metrics.
Fallback handling: If GPT-4.1 is unavailable, the system uses rule-based scoring to maintain basic lead qualification. If company enrichment fails, it falls back to domain analysis where possible.
System architecture Diagram

Benefits
- Hot leads reach a rep in seconds, not hours, the moment a high-intent submission arrives, a Slack alert lands in the right channel with everything the rep needs to act
- Consistent, bias-free scoring: every lead is evaluated against the same GPT-4.1 criteria, removing the inconsistency of human triage
- Company intelligence without manual research: reps open a Slack alert and already know the company’s industry, size, and tech stack
- Zero-downtime resilience: if the AI API goes down, rule-based fallback scoring keeps the pipeline running
- Unified lead history: repeat contacts are detected, and interactions are appended to the original record, preserving full context
- Clean data from day one: lead sources are tracked, free email submissions are flagged, and all records share a consistent schema
- Scalable without config changes: new lead sources plug in via the webhook endpoint; the pipeline handles volume automatically
Dashboard overview
Lead analysis results panel
The lead form renders a live results card immediately after submission, displaying the AI score, category, intent rating, budget signal, urgency level, ICP match, and a plain-English summary of why the lead scored the way it did, along with a specific recommended next action.
Renders in the browser within ~2 seconds of form submission
Slack alert panel
When a lead is classified as HOT, a Block Kit alert fires to the configured Slack channel. The message includes: lead name and company, email, phone, all five scoring dimensions, the AI-generated summary, recommended action, estimated deal size, and assigned sales team, formatted as a structured card with section dividers.
Delivered to the #sales-alerts channel within seconds of submission
Analytics dashboard
The /dashboard page provides a live operations view of all processed leads: total volume, HOT / WARM / COLD breakdown, average score, conversion rate, leads today, leads this week, top sources by volume, and a filterable lead feed. Data is drawn directly from the in-memory store and refreshes on page load.
Accessible at /dashboard: no login required in base configuration
Project evolution & key milestones
The system scope grew significantly from the initial lead scoring proof-of-concept. Key additions and refinements delivered across the project lifecycle:
Core scoring engine
- Initial GPT-4 integration replaced with GPT-4.1 for faster, more consistent structured output
- AI temperature set to 0.3 after testing: balances consistency with contextual sensitivity
- Strict JSON output schema enforced via system prompt to eliminate parsing failures
- Rule-based fallback engine added to ensure zero downtime when the OpenAI API is unavailable
- Score validation and sanitisation layer added (score clamped 0–100; category constrained to enum)
Enrichment layer
- Clearbit integration added as the primary enrichment source for business email domains
- Domain-only fallback implemented: company name inference, TLD region mapping, business email detection
- Free email provider list maintained to skip enrichment for Gmail, Yahoo, Hotmail, iCloud, ProtonMail, and similar
Alerting system
- Slack alerts upgraded from plain text to full Block Kit format with eight labelled fields and section dividers
- Tiered routing logic added: HOT → Slack, WARM → nurture queue, COLD → archive
- All notification steps moved to asynchronous execution to keep main API response time under two seconds
- CRM push also made non-blocking: Airtable delays no longer affect the caller experience
Data and integration
- n8n webhook route added (/api/webhook/n8n) to support visual workflow orchestration
- Embedded form endpoint added (/api/webhook/form) for third-party form providers
- Importable n8n workflow JSON file shipped with the project for instant setup
- Airtable CRM integration added with 18 mapped fields; designed as a swappable service module
Memory layer and analytics
- Repeat lead detection added: duplicate email submissions update the existing record rather than creating a new one
- Interaction history log added to each lead record for full contact context
- Analytics aggregation engine built into the storage service: computes category counts, average score, conversion rate, score distribution, top sources, and temporal metrics on demand
- Dashboard feed endpoint added with configurable pagination and category/source filters
Security and production hardening
- Helmet HTTP security headers added across all routes
- Rate limiter set to 100 requests per 15 minutes per IP on all /api/* routes
- Request body size capped at 1 MB to prevent oversized payload attacks
- Explicit timeouts set on all external API calls (OpenAI: 30s · Clearbit: 5s · Airtable: 10s · Slack: 5s)
- Global error handler middleware added to prevent stack traces leaking to API callers
Data flow architecture
How data moves through each stage and at what cadence, a key reference for ops teams integrating this system into existing stacks:
| Stage | Source | Destination | Trigger |
|---|---|---|---|
| Intake | Form / API / n8n webhook | Express backend | On submission (real-time) |
| Enrichment | Clearbit API / domain analysis | Lead record (in memory) | Per lead, synchronous |
| AI Scoring | OpenAI GPT-4.1 | Lead record (in memory) | Per lead, synchronous |
| CRM Push | In-memory lead record | Airtable (18 fields) | Per lead, async (non-blocking) |
| Slack Alert | In-memory lead record | Slack channel (HOT only) | Per lead, async (non-blocking) |
| Dashboard | In-memory lead store | Browser via /dashboard | On page load / manual refresh |
Note
The current storage layer uses an in-memory Map for speed and simplicity. For production deployments requiring persistence across restarts or horizontal scaling, this is designed to be swapped for PostgreSQL, Supabase, or MongoDB, the storage service exposes a clean interface with no direct database calls in the route layer.
Lead scoring & classification
The AI scoring engine evaluates every lead across five weighted dimensions and assigns a 0–100 score. Classification thresholds are:
| Category | Score Range | Routing Action | Criteria |
|---|---|---|---|
| HOT | 80 – 100 | Immediate Slack alert + rep assignment | Clear budget, urgency signal, decision-maker identified, strong ICP match |
| WARM | 50 – 79 | Added to nurture email sequence | Some buying signals, partial ICP match, needs further qualification |
| COLD | 0 – 49 | Archived, no immediate action | No clear intent, no budget signals, poor ICP fit or generic enquiry |
The five scoring dimensions GPT-4.1 evaluates are:
- Budget: explicit dollar amounts, investment language, company size inference
- Urgency: timeline pressure, ASAP / deadline keywords, quarter-based mentions
- Intent: active buying vs. passive browsing language (“want to buy” vs. “just exploring”)
- ICP Match: B2B vs. B2C, company size (50–500 employees = Excellent), industry alignment
- Email Quality: business domain vs. free provider (Gmail, Yahoo, Hotmail, etc.)

Technology Stack:
| Technology | Purpose |
|---|---|
| Node.js & Express | Backend API and lead processing |
| OpenAI GPT-4.1 | AI lead scoring and qualification |
| n8n | Workflow automation and webhook integration |
| Clearbit | Company data enrichment |
| Slack | Real-time alerts for HOT leads |
| Airtable | Lead records and CRM integration |
| SMTP / Email | Lead nurturing and email notifications |
Closing Summary
This project combines AI-powered lead scoring, company enrichment, and automated sales routing to help teams prioritize prospects, streamline follow-ups, and manage leads more efficiently through a centralized dashboard.