n8n Masterclass IModule 4

4.1Lead Generation Pipeline — LinkedIn to Google Sheets to Email

30 min 8 code blocks Practice Lab Quiz (4Q)

Lead Generation Pipeline — LinkedIn to Google Sheets to Email

Imagine waking up to 50 qualified leads in your Google Sheet, each one already enriched with company info, a personalized email draft waiting in your outbox, and a WhatsApp notification telling you which leads are "hot." In Pakistan's growing freelance and agency market, the difference between a PKR 50,000/month freelancer and a PKR 300,000/month agency owner often comes down to one thing: automated lead generation. This lesson builds that exact pipeline from scratch using n8n — the same system that a Karachi-based digital agency uses to generate 200+ qualified leads per month without any manual prospecting.

Section 1: The Full Pipeline Architecture

code
LEAD GENERATION PIPELINE — 3-STAGE ARCHITECTURE
═══════════════════════════════════════════════════════════════

  STAGE 1: LEAD CAPTURE
  ├── Source A: Webhook (receives LinkedIn data from scraper)
  ├── Source B: CSV upload (manual batch import)
  ├── Source C: Web form (landing page submission)
  └── Source D: RSS/API (job board monitoring for hiring signals)
         │
         ▼
  STAGE 2: ENRICHMENT & SCORING
  ├── Hunter.io → Find verified email address
  ├── Company website → Tech stack detection (Wappalyzer)
  ├── AI Node → Score lead 0-100 based on ideal client profile
  ├── AI Node → Generate personalized pitch hook
  └── Data merges into single enriched lead object
         │
         ▼
  STAGE 3: DISTRIBUTION & ACTION
  ├── Score >= 60 → Google Sheets (Hot Leads)
  │   ├── Gmail → Create personalized email draft
  │   ├── WhatsApp/Slack → Alert: "New hot lead!"
  │   └── CRM → Create deal (if using HubSpot/Pipedrive)
  │
  └── Score < 60 → Google Sheets (Cold Leads)
      └── Monthly nurture sequence (revisit later)

═══════════════════════════════════════════════════════════════

The n8n Workflow Structure

code
[Webhook Trigger / CSV Upload]
       │
       ▼
[HTTP Request: Hunter.io email lookup]
       │
       ▼
[AI Node: Lead scoring + pitch generation]
       │
       ▼
[IF Node: score >= 60?]
   │                    │
   YES                  NO
   │                    │
   ▼                    ▼
[Google Sheets:      [Google Sheets:
 Hot Leads]           Cold Leads]
   │
   ▼
[Gmail: Draft personalized email]
   │
   ▼
[WhatsApp/Slack: Notify team]

Section 2: Building the Workflow Node by Node

Node 1 — Webhook Trigger

Create a new workflow. Add a Webhook node. Set method to POST. Copy the production URL — this is where your lead data arrives.

Expected payload format:

json
{
  "name": "Ahmed Khan",
  "company": "TechStartup Karachi",
  "linkedin_url": "https://linkedin.com/in/ahmedkhan",
  "title": "CEO",
  "website": "techstartup.pk"
}

Lead sources that feed this webhook:

SourceToolCostLeads/Month
LinkedIn Sales NavigatorPhantombuster$56/month500-2,000
LinkedIn free searchApify LinkedIn scraper$49/month (Apify)200-500
Google MapsApify Google Maps scraper$49/month500-5,000
Job boards (Rozee.pk)Custom scraper / RSSFree100-300
Website formsn8n Webhook (direct)FreeDepends on traffic

Node 2 — Hunter.io Email Lookup

code
HTTP Request Configuration:
  Method: GET
  URL: https://api.hunter.io/v2/email-finder
       ?domain={{$json.website}}
       &first_name={{$json.name.split(' ')[0]}}
       &last_name={{$json.name.split(' ')[1]}}
       &api_key=YOUR_HUNTER_KEY

  Parse response: $json.data.email

  Hunter.io free tier: 25 lookups/month
  Hunter.io Starter ($49): 500 lookups/month
  Alternative: Snov.io ($39 for 1,000 lookups)

Node 3 — AI Lead Scoring

code
AI SCORING PROMPT:

Score this lead from 0-100 for a Karachi-based digital agency
that sells AI automation services to Pakistani businesses.

Lead Data:
  Name: {{$json.name}}
  Title: {{$json.title}}
  Company: {{$json.company}}
  Website: {{$json.website}}

Scoring Criteria:
  - Decision-maker status (40 points):
    CEO/Founder/Owner = 40, VP/Director = 30,
    Manager = 20, Other = 10
  - Company size/budget signals (30 points):
    Has website + active social = 30,
    Has website only = 20, No website = 5
  - Relevance to AI automation (30 points):
    Tech/e-commerce/agency = 30,
    Restaurant/retail = 20, Other = 10

Return ONLY valid JSON:
{"score": NUMBER, "reason": "ONE SENTENCE",
 "pitch_hook": "ONE PERSONALIZED OPENING LINE"}

Node 4 — IF Condition (Lead Routing)

code
LEAD ROUTING LOGIC
═══════════════════════════════════════════════════════════════

  Score 80-100: HOT LEAD
  ├── → Hot Leads Sheet (immediate follow-up)
  ├── → Gmail draft with personalized pitch
  ├── → WhatsApp alert to you: "HOT LEAD: [Name] at [Company]"
  └── → CRM: Create deal with "Warm" status

  Score 60-79: WARM LEAD
  ├── → Warm Leads Sheet
  ├── → Gmail draft (generic template)
  └── → Weekly batch review

  Score 0-59: COLD LEAD
  ├── → Cold Leads Sheet (nurture list)
  └── → Monthly review for re-scoring

═══════════════════════════════════════════════════════════════

Node 5 — Google Sheets Append

Map columns: Name | Company | Title | Email | Website | Score | Reason | Pitch Hook | Date

This becomes your live lead database. Share the Sheet (read-only) with your sales team for follow-up.

Node 6 — Gmail Draft

code
Gmail Node Configuration:
  Operation: Create Draft (NOT Send — keeps human in the loop)

  Subject: Quick question for {{$json.name}} at {{$json.company}}

  Body:
  Hi {{$json.name.split(' ')[0]}},

  {{$json.pitch_hook}}

  I help Pakistani businesses like {{$json.company}} automate
  their operations with AI — saving 20-40 hours per month on
  manual tasks.

  Would you be open to a 15-minute call this week?

  Best,
  [Your Name]
  [Your Agency Name] | Karachi

Why drafts, not sends? Gmail drafts keep a human in the loop. You review each draft before sending. This protects your sender reputation and prevents bad AI-generated pitches from reaching prospects.

Section 3: Scaling the Pipeline

Scale LevelLeads/MonthTools NeededMonthly Cost
Starter50-100Hunter.io free + Gemini freePKR 0
Growth200-500Hunter.io Starter + PhantombusterPKR 28,000
Agency1,000-5,000Snov.io + Apify + WATI alertsPKR 45,000
Enterprise5,000+Custom scraping + multiple enrichment APIsPKR 80,000+

Preventing Duplicate Leads

Add a deduplication step before enrichment:

code
DEDUPLICATION LOGIC:
  1. Before enrichment, check if email/website exists in Sheets
  2. Google Sheets Search Row: match on email column
  3. IF match found → Skip (already in pipeline)
  4. IF no match → Continue to enrichment

  This prevents wasting Hunter.io credits on leads you already have.
Practice Lab

Practice Lab

Exercise 1: Webhook + Sheets — Build the webhook → Google Sheets path first. Use n8n's test webhook to send 5 dummy Pakistani company leads (Rozee.pk, Foodpanda PK, Daraz, Jazz, Telenor Pakistan). Confirm rows appear correctly in your sheet with all fields.

Exercise 2: Hunter.io Integration — Add the Hunter.io node. Test with a real domain you own or a public company domain. If Hunter returns no credits, substitute with a mock HTTP node that returns {"data": {"email": "test@domain.com"}} for testing. Verify the email flows through to the Set node correctly.

Exercise 3: AI Scoring — Add the AI scoring node with the prompt above. Feed it 5 test leads with varying titles (CEO, Manager, Intern) and industries. Verify scores make sense: CEO of tech company should score 80+, intern at unrelated industry should score <30. Tune the prompt if scores feel off.

Exercise 4: Full Pipeline Run — Connect all nodes end-to-end. Send 10 test leads through the webhook. Verify: hot leads go to the Hot sheet, cold leads go to the Cold sheet, Gmail drafts appear in your Drafts folder, and a notification fires for hot leads. Export the workflow as JSON and save it as lead-gen-pipeline-v1.json.

Pakistan Case Study

Karachi Digital Agency — 0 to 200 Qualified Leads/Month

A 2-person digital agency in Clifton, Karachi was spending 15 hours per week on manual prospecting: searching LinkedIn, finding emails, writing personalized pitches. They were generating ~30 leads per month with a 5% response rate — 1-2 meetings per month.

Their n8n Pipeline:

ComponentConfigurationSetup Time
Lead sourcePhantombuster LinkedIn scraper → 500 profiles/week1 hour
WebhookReceives Phantombuster output, fires for each lead15 min
Hunter.ioEmail lookup (Starter plan: 500/month)15 min
AI ScoringGemini 2.5 Flash, scoring prompt tuned for PK agencies30 min
Google SheetsHot/Warm/Cold tabs, shared with team15 min
Gmail DraftsPersonalized pitch with AI-generated hook20 min
WhatsApp AlertWATI webhook for score 80+ leads15 min
Total3 hours setup

Results After 60 Days:

MetricBefore (Manual)After (n8n Pipeline)Change
Leads generated/month30200++567%
Time on prospecting15 hours/week2 hours/week (reviewing drafts)-87%
Email response rate5% (generic pitches)12% (AI-personalized)+140%
Monthly meetings booked1-28-12+500%
Monthly revenue from new clientsPKR 50,000PKR 280,000+460%
Cost (tools)PKR 0PKR 28,000/monthNew cost
Net revenue increasePKR 202,000/month

Agency Owner's Insight: "Pehle main 15 ghante LinkedIn pe scroll karta tha aur 30 leads milti theen. Ab 200+ leads automatically aati hain, har ek scored aur personalized pitch ke saath. Mera kaam sirf drafts review karna hai. 3 ghante ka setup tha — 60 din mein revenue 5x ho gaya."

Key Takeaways

  • A three-stage pipeline (Capture → Enrich → Distribute) is the production standard for any serious lead-gen automation — building it in n8n takes 3-4 hours
  • Hunter.io's free tier gives 25 searches/month — enough to validate the pipeline before investing in a paid plan
  • AI lead scoring with a clear rubric (decision-maker status + budget signals + relevance) eliminates the guesswork from prioritizing prospects
  • Always log ALL leads (not just hot ones) to separate sheets — your "cold list" from today is next month's warm follow-up sequence
  • The Gmail draft node creates drafts, not sends — this human-in-the-loop approach protects your sender reputation and prevents bad AI pitches from going out
  • AI-personalized email pitches get 2-3x higher response rates than generic templates — the pitch hook generated alongside the lead score is your opening line
  • Deduplication (check if lead exists before enriching) prevents wasting Hunter.io credits on prospects already in your pipeline
  • Pakistani agencies can go from 30 manual leads/month to 200+ automated leads/month with PKR 28,000/month in tools — the ROI is 7-10x within 60 days
  • Export your completed pipeline as JSON (lead-gen-pipeline-v1.json) — this becomes a deployable product you can sell to other agencies for PKR 50,000-100,000 per setup

Lesson Summary

Includes hands-on practice lab8 runnable code examples4-question knowledge check below

Quiz: Lead Generation Pipeline — LinkedIn to Google Sheets to Email

4 questions to test your understanding. Score 60% or higher to pass.