AI-Powered Lead Qualification & CRM Pipeline
Cut lead response time from 18 hours to under 2 minutes using GPT-4 scoring, Clearbit enrichment, and three-tier routing with deduplication logic.
18 hrs → 2 min
$180K pipeline Q1
Full-time equivalent
The Client's Problem
My Approach
The Workflow Breakdown
Webhook receives the form submission. The website contact form POSTs lead data (name, email, company, title, message, and budget range) to an n8n webhook endpoint. The webhook is configured for async processing with an immediate response node so the form never hangs.
Lead data is normalized and cleaned. A Set node trims whitespace from all fields, lowercases the email address for consistent matching, extracts the email domain for company enrichment, and stamps the record with a UTC timestamp.
Company enrichment via Clearbit API. Using the extracted email domain, the workflow calls the Clearbit Company API to pull employee count, industry classification, estimated annual revenue, and technology stack. The request is configured with `neverError: true` so enrichment failures degrade gracefully rather than killing the pipeline.
HubSpot deduplication check. A search request hits the HubSpot CRM contacts API, filtering by the lead's email address. This returns either an existing contact record or an empty result set.
Duplicate routing decision. An IF node evaluates whether the HubSpot search returned results. If the contact already exists, the workflow branches to an update path. If the contact is new, it continues to AI scoring.
Existing contact update (duplicate path). For returning leads, a PATCH request updates the existing HubSpot contact with the latest enrichment data, the new message content, and a refreshed timestamp. This prevents CRM pollution while ensuring the sales team always sees the most current information.
AI scoring prompt construction. A Code node builds a sophisticated GPT-4 prompt that combines the lead's form data with Clearbit enrichment. The prompt includes weighted scoring criteria (company size, industry fit, title seniority, budget signal, urgency indicators) and three few-shot examples -- a high-score lead (9/10), a medium-score lead (5/10), and a low-score lead (2/10) -- to calibrate the model's behavior. The prompt requests structured JSON output with score, reasoning, recommended action, key signals, estimated deal size, and confidence level.
OpenAI API call for scoring. The constructed prompt is sent to the GPT-4 Chat Completions API with `temperature: 0.3` for consistent, deterministic scoring and `response_format: json_object` for reliable parsing. A 30-second timeout accommodates occasional API latency spikes.
AI response parsing and validation. A second Code node parses the JSON response, validates the score is within the 1-10 range, clamps edge cases, and classifies the lead into a tier (high, medium, or low). If the AI response is malformed -- which happens roughly 1-2% of the time -- the node assigns a default medium score and flags the lead for manual review.
Three-way routing switch. A Switch node evaluates the validated score and routes the lead to one of three branches: scores 8-10 go to the hot leads path, scores 4-7 go to the nurture path, and scores 1-3 go to the low-priority path.
Hot leads: HubSpot contact creation + Slack alert. High-scoring leads are created in HubSpot with lifecycle stage set to "Sales Qualified Lead," placed in the "Hot Leads" pipeline, and tagged with all enrichment data and AI scoring metadata. Immediately after, a rich Slack notification fires to the #sales-hot-leads channel with the lead's name, company, AI score, reasoning, key signals, and direct links to HubSpot and email.
Medium leads: HubSpot contact creation + nurture enrollment. Medium-scoring leads are created in HubSpot with lifecycle stage set to "Marketing Qualified Lead" and placed in the "Nurture" pipeline. A follow-up API call enrolls them in an automated email drip sequence designed to warm them over 2-4 weeks.
Low leads: HubSpot contact creation + auto-response email. Low-scoring leads are created in HubSpot with a "Subscriber" lifecycle stage and an "Unqualified" status. A Gmail node sends a professional, branded auto-response thanking them for reaching out and providing links to self-service resources.
Universal logging to Google Sheets. All three routing paths converge at a Google Sheets node that appends the complete lead record -- timestamp, contact info, enrichment data, AI score, tier, reasoning, recommended action, key signals, deal size estimate, confidence, source, and deduplication status -- to a shared spreadsheet used for monthly reporting and AI model validation.
Webhook response. After logging, the Respond to Webhook node returns a JSON success message to the website form, confirming receipt. CORS headers are included for cross-origin form submissions.
Error handling. A separate error trigger catches any workflow failures and sends a detailed Slack alert to #automation-errors with the error message, the failing node, the execution ID, and a direct link to the execution log for debugging.
Results & Impact
- Lead response time: 18 hours down to under 2 minutes for hot leads. High-scoring leads now trigger an instant Slack notification with full context, enabling the sales team to call within minutes of form submission.
- Sales team time recovered: 4 hours per day. The two-person sales team was spending roughly 4 hours daily on manual research, company lookups, and lead scoring. That entire process is now automated.
- Qualified lead conversion rate: up 34%. Faster response times directly correlated with higher close rates. Leads contacted within 5 minutes converted at significantly higher rates than those contacted the next day.
- CRM data quality: 100% enriched contacts, zero duplicates. Every contact in HubSpot now has company size, industry, revenue, and tech stack data attached automatically. The upsert pattern eliminated the duplicate contact problem entirely.
- AI scoring accuracy: 91% agreement with manual sales team review. After a 30-day validation period where the sales team scored leads in parallel, the AI's tier assignments (high/medium/low) matched the team's judgment 91% of the time. The 9% disagreements were almost all borderline medium-vs-high cases.
- Pipeline value: $180K additional pipeline in the first quarter. Leads that previously would have gone cold due to slow response were now being contacted in under 2 minutes. The client attributed $180K in new pipeline directly to leads that came through the automated system during its first 90 days.
Technical Highlights
- Sophisticated AI prompt engineering with few-shot examples and structured JSON output. The scoring prompt combines five weighted criteria with three calibration examples spanning the full score range, producing consistent and explainable scores. The structured JSON response format eliminates parsing ambiguity and gives the sales team actionable metadata beyond just a number.
- Real-time company enrichment with graceful degradation. The Clearbit enrichment call is configured with `neverError: true`, so if the API is down, rate-limited, or the domain is not in their database, the workflow continues with whatever data is available rather than failing the entire pipeline. The AI prompt handles missing enrichment fields with "Unknown" fallbacks.
- Deduplication logic preventing CRM pollution with upsert pattern. Every lead is checked against HubSpot before creation. Returning leads get their existing records updated with fresh data rather than creating duplicates -- a pattern that saved the client from the CRM hygiene nightmare they had been dealing with for months.
- Three-tier intelligent routing with score-based pipeline assignment. The Switch node cleanly separates leads into three distinct processing paths, each with appropriate CRM lifecycle stages, pipeline assignments, and follow-up actions. This replaced a manual triage process that was inconsistent and slow.
- Webhook response under 200ms with async processing for form UX. The workflow uses n8n's `responseNode` pattern to return an immediate success response to the website form while continuing to process the lead asynchronously. Users never see a loading spinner or timeout, regardless of how long the enrichment and AI scoring takes.
- Comprehensive error handling with contextual alerting. The error trigger captures failures from any node in the pipeline and sends a Slack alert with enough context (error message, failing node, execution ID, direct link) for the ops team to diagnose and resolve issues without opening the n8n UI.