Build a Lead Qualification AI Agent in n8n (Step-by-Step)
Complete walkthrough of building an autonomous AI agent that scores leads, enriches data from 3 APIs, and routes to the right sales rep — with zero manual intervention.
Lead qualification is the highest-ROI automation you can build for a B2B sales team. A well-built agent replaces 2–4 hours of daily SDR work, improves lead scoring accuracy, and routes high-intent prospects to senior reps before they go cold. Here's the exact architecture we deployed for a SaaS client last quarter.
What the Agent Does
- Triggers on new CRM lead (HubSpot webhook)
- Enriches the lead with company data (Clearbit), LinkedIn data (Proxycurl), and tech stack info (BuiltWith)
- Scores the lead 0–100 using GPT-4o with your ICP criteria as the system prompt
- Routes score ≥ 70 to senior AE (Slack DM + CRM task), score 40–69 to SDR sequence, score < 40 to nurture email
- Logs everything to Google Sheets for pipeline reporting
Prerequisites
You'll need:
- n8n (self-hosted or cloud)
- HubSpot with webhook access
- Clearbit API key (or Apollo.io as an alternative)
- OpenAI API key
- Slack bot token with DM permissions
Step 1: Webhook Trigger
In n8n, create a new workflow and add a Webhook node. Set the method to POST and copy the webhook URL. In HubSpot, go to Settings → Integrations → Webhooks and create a new subscription for contact.creation. Paste the n8n URL as the target.
Test by creating a dummy contact — n8n's webhook will capture the payload so you can inspect the structure.
Step 2: Data Enrichment (3 Parallel HTTP Calls)
Add a Split In Batches node, then three HTTP Request nodes running in parallel:
- Clearbit Enrichment:
GET https://person.clearbit.com/v2/combined/find?email={{email}}— returns company size, industry, funding, LinkedIn URL, location - Proxycurl LinkedIn:
GET https://nubela.co/proxycurl/api/v2/linkedin?linkedin_profile_url={{linkedin_url}}— returns title, seniority, connections - BuiltWith API:
GET https://api.builtwith.com/free1/api.json?KEY={{key}}&LOOKUP={{domain}}— returns tech stack tags (Salesforce, Stripe, AWS, etc.)
Merge the results using a Merge node (mode: Merge By Index) so all enrichment data lands on the same item.
Step 3: AI Scoring with GPT-4o
Add an OpenAI node set to Chat Completion. Use this system prompt structure:
You are a B2B lead qualification expert. Score this lead from 0-100 based on our ICP:
- Ideal company size: 50-500 employees
- Ideal industries: SaaS, FinTech, Healthcare
- Must be decision-maker: VP level or above
- Strong signal: uses Salesforce or HubSpot
- Strong signal: Series A or B funded
Return ONLY a JSON object: {"score": number, "reasoning": "string", "priority": "high|medium|low"}
Lead data: {{JSON.stringify($json)}}
Parse the JSON response with a Code node using JSON.parse($input.first().json.choices[0].message.content).
Step 4: Routing Logic
Add an IF node checking score >= 70. For the true branch (high priority):
- Slack node: DM the senior AE with lead summary and score reasoning
- HubSpot node: Create a task assigned to that AE, set lead stage to "SQL"
For score 40–69, trigger an email sequence. For under 40, add to a nurture list.
Step 5: Logging
Add a Google Sheets node at the end of all branches to append a row: timestamp, lead email, company, score, reasoning, routing decision. This becomes your qualification audit trail.
Results from Our Client Deployment
After 90 days running this agent for a Series B SaaS company:
- SDR time on manual qualification: reduced from 3.5 hrs/day → 15 min/day (review only)
- Lead response time: 4 hours → 8 minutes for high-score leads
- Qualification accuracy: 73% match vs. human judgment (up from 61% pre-agent)
- Pipeline impact: 22% increase in SQL-to-opportunity conversion
Want this built for your sales team? Book an automation audit and we'll scope it out in 60 minutes.
Your Competitors Are Already
Automating. Are You?
Book a free 60-minute automation audit and walk away with a custom roadmap showing exactly where your business can save time and money — at no cost, no risk.