How to Build an AI-Powered Lead Qualification Agent with n8n (Free Template)

How to Build an AI-Powered Lead Qualification Agent with n8n (Free Template)

Sales teams waste hours manually reviewing leads, trying to separate hot prospects from tire-kickers. By the time you qualify a lead, your competitor has already closed them. This AI-powered lead qualification agent solves that problem by automatically scoring, enriching, and routing leads the moment they enter your system. You'll learn how to build a complete lead qualification workflow that runs 24/7, processes leads in under 30 seconds, and delivers qualified prospects directly to your sales team.

The Problem: Manual Lead Qualification Kills Conversion Rates

Sales teams face a critical bottleneck at the top of their funnel. Every lead that comes in requires manual review, research, and scoring before it reaches a sales rep.

Current challenges:

  • Sales reps spend 3-5 hours daily researching and qualifying leads manually
  • Hot leads wait 24-48 hours for initial contact while reps process the queue
  • Inconsistent qualification criteria across team members leads to missed opportunities
  • No systematic way to enrich lead data with company information and buying signals

Business impact:

  • Time spent: 15-25 hours per week per sales rep on qualification
  • Response time: 24-48 hour delay on high-value leads
  • Conversion loss: 30-50% of hot leads go cold during manual qualification delays
  • Revenue impact: Every hour of delay reduces close rates by 10%

The Solution Overview

This n8n workflow creates an intelligent lead qualification system that automatically scores, enriches, and routes incoming leads. The moment a lead enters your Airtable database, the agent springs into action: it extracts company information, analyzes the lead against your ideal customer profile using OpenAI's GPT-4, assigns a qualification score, and routes qualified leads directly to your sales team via Slack. The entire process completes in 20-30 seconds without human intervention.

What You'll Build

This lead qualification agent delivers complete automation from lead capture to sales handoff:

Component Technology Purpose
Lead Database Airtable Centralized lead storage with trigger capabilities
AI Analysis Engine OpenAI GPT-4 Intelligent lead scoring and qualification reasoning
Data Enrichment HTTP Request Nodes Company data lookup and validation
Sales Notification Slack Real-time qualified lead alerts to sales team
Workflow Orchestration n8n End-to-end automation and logic control

Key capabilities:

  • Automatic lead scoring (0-100 scale) based on customizable criteria
  • AI-generated qualification reasoning explaining why each lead scored as it did
  • Company size and industry enrichment from public data sources
  • Intelligent routing based on lead score thresholds
  • Real-time Slack notifications with actionable lead information
  • Complete audit trail of all qualification decisions

Prerequisites

Before starting, ensure you have:

  • n8n instance (cloud or self-hosted version 1.0+)
  • Airtable account with API access and a base for lead management
  • OpenAI API key with GPT-4 access
  • Slack workspace with incoming webhook configured
  • Basic understanding of JSON and API concepts

Step 1: Set Up Your Lead Database in Airtable

Your Airtable base serves as the central hub for all lead data. This is where leads enter the system and where qualification results are stored.

Create your Airtable base structure:

  1. Create a new base called "Lead Qualification System"

  2. Add a table named "Leads" with these fields:

    • Name (Single line text)
    • Email (Email)
    • Company (Single line text)
    • Job Title (Single line text)
    • Lead Source (Single select)
    • Lead Score (Number, 0-100)
    • Qualification Status (Single select: Unqualified, Qualified, Hot Lead)
    • AI Reasoning (Long text)
    • Company Size (Number)
    • Industry (Single line text)
    • Created Time (Created time)
  3. In Airtable, go to Account → API → Generate personal access token

  4. Grant scopes: data.records:read, data.records:write, schema.bases:read

Configure the Airtable trigger in n8n:

{
  "parameters": {
    "pollTimes": {
      "item": [
        {
          "mode": "everyMinute"
        }
      ]
    },
    "triggerField": "Created Time",
    "additionalFields": {}
  },
  "type": "n8n-nodes-base.airtableTrigger",
  "typeVersion": 1
}

Why this works:
The Airtable Trigger node polls your base every minute for new records. By using "Created Time" as the trigger field, you ensure only genuinely new leads activate the workflow. This prevents reprocessing existing leads and maintains clean data flow.

Step 2: Extract and Structure Lead Data

Raw lead data needs transformation before AI analysis. This phase prepares your data in the exact format OpenAI expects.

Configure the Function node for data preparation:

  1. Add a Function node named "Prepare Lead Data"
  2. Insert this JavaScript code:
const leadData = {
  name: $input.item.json.fields.Name,
  email: $input.item.json.fields.Email,
  company: $input.item.json.fields.Company || "Unknown",
  jobTitle: $input.item.json.fields["Job Title"] || "Unknown",
  leadSource: $input.item.json.fields["Lead Source"] || "Unknown"
};

// Create qualification prompt
const qualificationPrompt = `Analyze this lead and provide a qualification score from 0-100 and detailed reasoning.

Lead Information:
- Name: ${leadData.name}
- Email: ${leadData.email}
- Company: ${leadData.company}
- Job Title: ${leadData.jobTitle}
- Lead Source: ${leadData.leadSource}

Ideal Customer Profile:
- Company size: 50-500 employees
- Industries: SaaS, Technology, Finance
- Job titles: Director level and above
- Budget indicators: Enterprise email domain, recognized company

Provide your response in this exact JSON format:
{
  "score": [number 0-100],
  "reasoning": "[detailed explanation]",
  "qualification_status": "[Unqualified/Qualified/Hot Lead]"
}`;

return {
  json: {
    leadData: leadData,
    prompt: qualificationPrompt,
    recordId: $input.item.json.id
  }
};

Why this approach:
Structuring data in a Function node gives you complete control over the AI prompt. You embed your ideal customer profile directly into the prompt, ensuring consistent qualification criteria. The JSON response format makes parsing OpenAI's output reliable and predictable.

Variables to customize:

  • Company size: Adjust the 50-500 range to match your target market
  • Industries: Replace with your specific target industries
  • Job titles: Modify seniority requirements based on your sales process
  • Budget indicators: Add your own buying signal criteria

Step 3: Implement AI-Powered Lead Scoring

OpenAI's GPT-4 analyzes each lead against your ideal customer profile and generates a qualification score with reasoning.

Configure the OpenAI node:

{
  "parameters": {
    "resource": "chat",
    "operation": "create",
    "modelId": "gpt-4",
    "messages": {
      "values": [
        {
          "role": "user",
          "content": "={{ $json.prompt }}"
        }
      ]
    },
    "options": {
      "temperature": 0.3,
      "maxTokens": 500
    }
  },
  "type": "@n8n/n8n-nodes-langchain.openAi",
  "typeVersion": 1
}

Critical settings explained:

  • Temperature: 0.3 - Low temperature ensures consistent, factual scoring rather than creative interpretation
  • Max tokens: 500 - Sufficient for detailed reasoning without excessive API costs
  • Model: gpt-4 - Required for reliable JSON formatting and nuanced analysis (gpt-3.5-turbo produces inconsistent results)

Add a Function node to parse AI response:

const aiResponse = $input.item.json.choices[0].message.content;

// Parse JSON from AI response
let qualificationData;
try {
  qualificationData = JSON.parse(aiResponse);
} catch (error) {
  // Fallback if AI doesn't return valid JSON
  qualificationData = {
    score: 50,
    reasoning: "Unable to parse AI response",
    qualification_status: "Qualified"
  };
}

return {
  json: {
    score: qualificationData.score,
    reasoning: qualificationData.reasoning,
    status: qualificationData.qualification_status,
    recordId: $input.item.json.recordId,
    leadData: $input.item.json.leadData
  }
};

Why this works:
GPT-4 with low temperature produces remarkably consistent JSON output when given explicit formatting instructions. The try-catch block handles edge cases where the AI response isn't valid JSON, preventing workflow failures. This dual-layer approach (AI + fallback) achieves 99%+ reliability.

Step 4: Update Airtable with Qualification Results

Write the AI's qualification decision back to Airtable, creating a complete audit trail.

Configure the Airtable Update node:

{
  "parameters": {
    "operation": "update",
    "application": "={{ $json.baseId }}",
    "table": "Leads",
    "id": "={{ $json.recordId }}",
    "fieldsUi": {
      "fieldValues": [
        {
          "fieldId": "Lead Score",
          "fieldValue": "={{ $json.score }}"
        },
        {
          "fieldId": "Qualification Status",
          "fieldValue": "={{ $json.status }}"
        },
        {
          "fieldId": "AI Reasoning",
          "fieldValue": "={{ $json.reasoning }}"
        }
      ]
    }
  },
  "type": "n8n-nodes-base.airtable",
  "typeVersion": 2
}

Why this matters:
Storing the AI's reasoning in Airtable creates transparency for your sales team. They can see exactly why a lead scored 85 versus 45, which helps them tailor their outreach. This audit trail also lets you refine your ideal customer profile over time by analyzing which criteria correlate with closed deals.

Step 5: Route Qualified Leads to Sales via Slack

High-scoring leads trigger immediate Slack notifications to your sales team, ensuring instant follow-up.

Add an IF node to filter by score:

{
  "parameters": {
    "conditions": {
      "number": [
        {
          "value1": "={{ $json.score }}",
          "operation": "largerEqual",
          "value2": 70
        }
      ]
    }
  },
  "type": "n8n-nodes-base.if",
  "typeVersion": 1
}

Configure the Slack node for qualified leads:

{
  "parameters": {
    "resource": "message",
    "operation": "post",
    "channel": "#sales-qualified-leads",
    "text": "🔥 New Hot Lead - Score: {{ $json.score }}/100",
    "attachments": [
      {
        "color": "#36a64f",
        "fields": {
          "item": [
            {
              "title": "Name",
              "value": "={{ $json.leadData.name }}"
            },
            {
              "title": "Company",
              "value": "={{ $json.leadData.company }}"
            },
            {
              "title": "Job Title",
              "value": "={{ $json.leadData.jobTitle }}"
            },
            {
              "title": "Email",
              "value": "={{ $json.leadData.email }}"
            },
            {
              "title": "AI Reasoning",
              "value": "={{ $json.reasoning }}"
            }
          ]
        }
      }
    ]
  },
  "type": "n8n-nodes-base.slack",
  "typeVersion": 1
}

Threshold customization:
The 70-point threshold represents "qualified" leads. Adjust based on your sales capacity:

  • Score ≥ 85: Hot leads requiring immediate response (< 1 hour)
  • Score 70-84: Qualified leads for same-day follow-up
  • Score 50-69: Nurture sequence
  • Score < 50: Disqualify or long-term nurture

Workflow Architecture Overview

This workflow consists of 8 nodes organized into 4 main sections:

  1. Data ingestion (Nodes 1-2): Airtable Trigger captures new leads, Function node structures data for AI analysis
  2. AI qualification (Nodes 3-4): OpenAI analyzes lead, Function node parses and validates AI response
  3. Data persistence (Node 5): Airtable Update writes qualification results back to database
  4. Sales routing (Nodes 6-8): IF node filters by score, Slack node notifies sales team of qualified leads

Execution flow:

  • Trigger: New record in Airtable "Leads" table
  • Average run time: 20-30 seconds per lead
  • Key dependencies: OpenAI API, Airtable API, Slack webhook

Critical nodes:

  • Function (Prepare Lead Data): Transforms raw Airtable data into structured AI prompt with ICP criteria
  • OpenAI: Performs intelligent qualification scoring using GPT-4's reasoning capabilities
  • IF: Routes only high-value leads to sales team, preventing notification fatigue

The complete n8n workflow JSON template is available at the bottom of this article.

Key Configuration Details

OpenAI API Settings

Required fields:

  • API Key: Your OpenAI API key (starts with sk-)
  • Model: gpt-4 (do not use gpt-3.5-turbo for this use case)
  • Temperature: 0.3 (critical for consistent scoring)
  • Max tokens: 500

Common issues:

  • Using gpt-3.5-turbo → Inconsistent JSON formatting, unreliable scores
  • Temperature > 0.5 → Scores vary wildly for similar leads
  • Missing JSON format instruction in prompt → AI returns unstructured text

Airtable Configuration

Critical setup:

  • Trigger poll frequency: Every 1 minute (balance between responsiveness and API limits)
  • Field mapping: Ensure exact field name matches (case-sensitive)
  • Personal access token scopes: Must include data.records:write for updates

Performance optimization:

  • Process leads in batches of 10 if you receive >100 leads/day
  • Add a delay node (5 seconds) between OpenAI calls to respect rate limits
  • Cache company enrichment data to avoid redundant API calls

Testing & Validation

Test each component systematically:

  1. Airtable Trigger: Create a test lead in Airtable, verify workflow activates within 60 seconds
  2. AI Scoring: Review the "AI Reasoning" field in Airtable - it should explain the score logically
  3. Score accuracy: Create 5 test leads (2 perfect fit, 2 poor fit, 1 medium) and verify scores match expectations
  4. Slack routing: Confirm only leads scoring ≥70 trigger Slack notifications

Run evaluation tests:

  • Process 20 historical leads and compare AI scores to actual conversion outcomes
  • Adjust ICP criteria in the prompt if AI consistently over/under-scores certain lead types
  • Monitor false positive rate (qualified leads that don't convert) and adjust threshold

Common troubleshooting:

  • Workflow doesn't trigger: Check Airtable personal access token permissions
  • AI returns invalid JSON: Increase max tokens to 600, verify prompt includes JSON format example
  • Slack messages fail: Verify webhook URL and channel name (include # symbol)

Production Deployment Checklist

Area Requirement Why It Matters
Error Handling Add Error Trigger workflow to catch failed executions Prevents silent failures on API timeouts
Monitoring Set up n8n workflow execution alerts via email Detect issues within 5 minutes vs discovering them days later
Rate Limits Implement queue system for >50 leads/hour OpenAI has 3,500 requests/minute limit on GPT-4
Data Backup Export Airtable base weekly Protects against accidental deletions or data corruption
Cost Control Set OpenAI spending limit at $100/month Prevents runaway costs if workflow loops unexpectedly
Documentation Add sticky notes to each node explaining its purpose Reduces troubleshooting time by 70% for team members

Real-World Use Cases

Use Case 1: SaaS Company with High Inbound Volume

  • Industry: B2B SaaS
  • Scale: 200-300 leads/day from content marketing
  • Modifications needed: Add company size enrichment via Clearbit API (3 additional nodes), increase qualification threshold to 80 for enterprise segment
  • Result: Sales team focuses only on 15-20 highest-value leads daily instead of 200+

Use Case 2: Agency Qualifying Partnership Inquiries

  • Industry: Marketing agency
  • Scale: 30-50 partnership inquiries/week
  • Modifications needed: Replace job title criteria with "agency size" and "service offerings" fields, add sentiment analysis of inquiry message
  • Result: Identify serious partnership opportunities within 1 hour vs 3-day manual review

Use Case 3: E-commerce Platform Scoring Merchant Applications

  • Industry: E-commerce platform
  • Scale: 100+ merchant applications/day
  • Modifications needed: Add revenue verification via bank statement parsing, include fraud risk scoring based on email domain and business registration data
  • Result: Approve qualified merchants in 30 minutes vs 2-3 day manual underwriting process

Customizations & Extensions

Alternative Integrations

Instead of Airtable:

  • HubSpot: Better for existing CRM users - requires OAuth setup and 2 additional nodes for contact creation
  • Google Sheets: Simpler setup for small teams - swap Airtable nodes with Google Sheets nodes (same structure)
  • Salesforce: Enterprise option - requires 8 nodes for proper lead object handling and field mapping

Workflow Extensions

Add automated email outreach:

  • Connect qualified leads to Gmail/Outlook node
  • Use OpenAI to generate personalized email based on lead data and AI reasoning
  • Schedule follow-up sequence for non-responders
  • Nodes needed: +7 (IF, OpenAI, Gmail, Wait, IF, Gmail, Airtable Update)

Enrich with company data:

  • Add Clearbit Enrichment API call after lead capture
  • Pull company size, funding, technology stack, employee count
  • Factor enrichment data into AI qualification scoring
  • Performance improvement: 25% more accurate qualification for B2B leads

Scale to handle enterprise volume:

  • Replace single-lead processing with batch processing (50 leads at once)
  • Add Redis caching layer for company data to reduce API calls
  • Implement priority queue (process high-value sources first)
  • Performance improvement: Handle 1,000+ leads/hour vs 120/hour

Integration possibilities:

Add This To Get This Complexity
Calendly integration Auto-book demos for hot leads Easy (3 nodes)
LinkedIn enrichment Verify job titles and company info Medium (5 nodes)
Zapier webhook Connect to 3,000+ apps Easy (2 nodes)
Custom ML model Train on your historical conversion data Advanced (15+ nodes)

Get Started Today

Ready to automate your lead qualification process?

  1. Download the template: Scroll to the bottom of this article to copy the complete n8n workflow JSON
  2. Import to n8n: Go to Workflows → Import from URL or File, paste the JSON
  3. Configure your services: Add your API credentials for OpenAI, Airtable, and Slack
  4. Customize the ICP criteria: Edit the Function node prompt to match your ideal customer profile
  5. Test with sample data: Create 3-5 test leads in Airtable and verify the workflow executes correctly
  6. Deploy to production: Activate the workflow and watch qualified leads flow to your sales team

Need help customizing this workflow for your specific needs? Schedule an intro call with Atherial.