Skip to content
ISHAsolankiPublic

About

An automated B2B lead generation and outreach pipeline built with n8n, leveraging Apollo.io for lead sourcing, OpenAI GPT-4o-mini for personalized email generation, Google Sheets for deduplication and tracking, and Gmail for delivery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

AI Lead Generation Pipeline

Automated B2B outreach pipeline built with n8n, OpenAI GPT-4o-mini, Apollo.io, Gmail and Google Sheets

n8n OpenAI Apollo.io Gmail Google Sheets


Problem Statement

Manual B2B lead generation is time-consuming, inconsistent, and difficult to scale. Sales teams spend hours finding contacts, writing personalized emails, tracking outreach, and managing follow-ups — all done manually with high risk of duplicate outreach and missed leads.

This project automates the entire outreach pipeline — from lead sourcing to personalized email delivery — using n8n as the automation backbone and OpenAI GPT-4o-mini for AI-powered personalization.


What It Does

This pipeline automates the entire B2B outreach process — from lead sourcing to personalized email delivery — without any manual intervention.

Target use case: Reaching Amazon FBA founders, brand owners, and eCommerce entrepreneurs at scale.


Pipeline Stages

Stage Node Description
1 HTTP Request Fetches contacts from Apollo.io via REST API
2 Split Out Splits contact array into individual leads
3 Google Sheets Loads previously contacted leads for dedup
4 Merge Filters out already-contacted leads
5 AI Agent (GPT-4o-mini) Generates personalized email per lead
6 Google Sheets Logs each lead with timestamp and status
7 Gmail Sends personalized email automatically

n8n Nodes Used

  • Manual Trigger / Schedule Trigger
  • HTTP Request — Apollo.io API calls
  • Edit Fields (Set) — Data transformation
  • Split Out — Array to individual items
  • Google Sheets (Get Rows + Append Row)
  • Merge — Deduplication logic
  • AI Agent + OpenAI Chat Model
  • Gmail — Send message

Workflow Node Map

The following describes the complete node chain in the n8n canvas:

Start Pipeline → Fetch Apollo Contacts → Extract Contacts Array → Split Into Individual Leads

Load Contacted Leads (Google Sheets) → Filter Already Contacted (Merge) → AI Email Writer (AI Agent + GPT-4o-mini) → Log Lead to Tracker (Google Sheets) → Send Outreach Email (Gmail)


Tech Stack

  • Automation Engine: n8n (Docker, localhost:5678)
  • Lead Source: Apollo.io (contacts/search API)
  • AI Model: OpenAI GPT-4o-mini
  • Email Delivery: Gmail (Google OAuth)
  • CRM/Tracker: Google Sheets
  • Deduplication: n8n Merge node (field matching on email)

Key Features

  • Fully automated end-to-end pipeline
  • AI-personalized emails per contact (name, title, company)
  • Built-in deduplication — no lead contacted twice
  • Audit trail in Google Sheets with timestamps
  • Modular design — each stage independently swappable
  • Scalable — supports up to 30 leads per run; increase per_page to scale

How To Run

  1. Install n8n via Docker:
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
  1. Import workflow/lead_gen_pipeline.json into n8n
  2. Add credentials: Apollo.io API key, OpenAI API key, Gmail OAuth, Google Sheets OAuth
  3. Create a Google Sheet named "Lead Tracker Apollo" with columns: Email, Name, Company, Status, Date Contacted
  4. Click "Execute workflow"

Challenges & Solutions

Apollo Free Plan API Restrictions

  • Challenge: The mixed_people/api_search endpoint (People Search) requires a paid Apollo plan. Attempting to use it returned a 403 Forbidden error.
  • Solution: Switched to the contacts/search endpoint, which is available on the free plan and queries the account's saved contacts. Leads are manually saved via Apollo's web UI, then processed automatically by the pipeline.

Email Field Unavailable on Free Plan

  • Challenge: Apollo's free plan does not return email addresses via the API. The email field returns as undefined.
  • Solution: For portfolio demonstration, the pipeline architecture is complete and functional. The Gmail node is configured with a fallback email for testing. Upgrading to a paid Apollo plan or integrating Hunter.io would resolve this in production.

Data Path Lost After Multiple Nodes

  • Challenge: After passing through the Google Sheets logging node, the AI Agent's output field ($json.output) became inaccessible in the Gmail node.
  • Solution: Used n8n's node reference syntax $('AI Agent').item.json.output to explicitly reference the AI Agent node's output regardless of intermediate nodes.

Portfolio Value & Skills Demonstrated

  • REST API integration — Apollo.io HTTP Request with master key authentication and custom headers
  • Data transformation — array extraction, splitting, and field mapping across nodes
  • AI prompt engineering — context-aware personalization using GPT-4o-mini
  • Deduplication logic — Merge node with field matching across two data streams
  • Google Sheets as lightweight CRM — read, compare, and append operations
  • Email automation — Gmail OAuth integration with dynamic content
  • End-to-end pipeline thinking — sourcing → filtering → personalization → logging → delivery

Future Improvements

  • Add follow-up email sequence — trigger 3 days after initial send if no reply
  • Integrate Hunter.io for email finding on free tier
  • Add Calendly link in outreach email for direct booking
  • Switch trigger to Schedule node for fully automated daily runs
  • Add error handling nodes for failed email sends
  • Expand to LinkedIn outreach using Phantombuster integration

Author

Isha, AI Automation Engineer

About

An automated B2B lead generation and outreach pipeline built with n8n, leveraging Apollo.io for lead sourcing, OpenAI GPT-4o-mini for personalized email generation, Google Sheets for deduplication and tracking, and Gmail for delivery.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors