How to Build an AI Lead Generation Agent
Build an AI agent that scrapes, scores, and outreach to fill your sales pipeline with 50 qualified leads per week.

Most founders I talk to are still doing lead gen like it's 2019. They're manually scrolling LinkedIn, copy-pasting emails into spreadsheets, writing one-off cold emails that sound like they were assembled by a committee, and then wondering why their pipeline looks like a desert in July.
Meanwhile, a solo founder running an AI lead generation agent out of a $200/month stack is booking 50+ demos a week while they sleep. The gap between these two realities is absurd, and it's only getting wider.
I'm going to walk you through exactly how to build this. Not theory. Not "wouldn't it be cool if." The actual stack, the actual code, and the actual numbers you can expect when you wire it all together.
Why Manual Lead Gen Is a Losing Game
Let's do some quick math that should make you uncomfortable.
A competent SDR spends roughly 20 hours a week on prospecting. They find maybe 100–200 contacts, send 50–80 personalized emails, and book—if they're good—5 to 10 meetings. That SDR costs you $60K–$80K a year fully loaded. Your cost per meeting is somewhere around $150–$300.
Now consider the AI agent version. An automated pipeline scrapes 1,000+ leads per day, scores them against your ICP in seconds, and fires off personalized outreach at scale. Typical results from real case studies: 5–12% reply rates, 50+ meetings per week, CPL between $10–$25.
That's not a marginal improvement. That's an order-of-magnitude shift.
The reason this works now—and didn't work three years ago—is that LLMs got good enough to do the two things that previously required a human brain: researching a prospect well enough to write something relevant, and deciding which prospects are actually worth contacting.
The Three-Stage Pipeline
Every effective AI lead generation agent follows the same basic architecture. You're building a pipeline with three stages, and each one matters.
Stage 1: Scraping — Finding the people who match your ideal customer profile. Stage 2: Scoring — Figuring out which of those people are actually worth your time. Stage 3: Outreach — Sending them something they'll actually respond to.
Miss any one of these and the whole thing falls apart. Scrape without scoring and you'll blast 10,000 irrelevant contacts. Score without good data and your model is garbage-in-garbage-out. Nail the first two but send generic outreach and you'll get flagged as spam.
Let's build each one.
Stage 1: Scraping — Building Your Lead List on Autopilot
You need raw contact data. Job titles, company names, emails, company size, recent funding, tech stack—whatever signals matter for your ICP. The goal is to go from "I need leads" to "I have 5,000 qualified contacts" in under two hours.
The tools that actually work:
Apify is my go-to for most scraping jobs. They have 5,000+ pre-built scrapers (they call them "Actors") for LinkedIn, Google Maps, Instagram, company websites—basically anything with public data. Pricing starts around $0.30/GB of compute, which works out to roughly $0.001–$0.05 per lead. You can scrape 10,000 leads in about two hours.
Bright Data is the heavy-duty option if you need scale or hard-to-reach data. They've got 72 million residential proxy IPs and pre-built datasets with 100M+ B2B emails. More expensive ($500/month gets you roughly 50K contacts), but the data accuracy is 95%+ with built-in email validation.
Here's a basic Apify scraper setup that pulls LinkedIn Sales Navigator results. You'd run this in Python:
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run_input = {
"searchUrl": "https://www.linkedin.com/sales/search/people?query=(filters:List((type:COMPANY_HEADCOUNT,values:List((id:D,text:51-200),(id:E,text:201-500))),(type:CURRENT_TITLE,values:List((text:VP%20of%20Marketing),(text:Head%20of%20Growth)))))",
"limit": 1000,
"proxy": {
"useApifyProxy": True,
"apifyProxyGroups": ["RESIDENTIAL"]
}
}
run = client.actor("anchor/linkedin-sales-navigator-search").call(run_input=run_input)
leads = []
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
leads.append({
"name": item.get("fullName"),
"title": item.get("title"),
"company": item.get("companyName"),
"linkedin_url": item.get("profileUrl"),
"location": item.get("location")
})
print(f"Scraped {len(leads)} leads")
From here, you enrich with emails. Apollo.io's API works well for this—you feed in a LinkedIn URL or name + company, and it returns verified email addresses. Their free tier gives you 10,000 credits a month, which is plenty to start.
import requests
def enrich_lead(name, company):
resp = requests.post("https://api.apollo.io/v1/people/match", json={
"api_key": "YOUR_APOLLO_KEY",
"name": name,
"organization_name": company
})
data = resp.json().get("person", {})
return {
"email": data.get("email"),
"phone": data.get("phone_numbers", [{}])[0].get("sanitized_number"),
"company_size": data.get("organization", {}).get("estimated_num_employees"),
"industry": data.get("organization", {}).get("industry"),
"funding": data.get("organization", {}).get("total_funding")
}
Compliance note that you should actually read: Don't skip this part. Use verified emails only (not scraped-and-guessed). Include unsubscribe links. Comply with GDPR if you're touching EU contacts. The fastest way to kill your domain reputation is to blast unverified addresses with no opt-out. This is a serious thing. Being thoughtful about compliance isn't a nice-to-have—it's what separates a sustainable pipeline from one that gets your domain blacklisted in week three.
Stage 2: Scoring — The Part Everyone Skips (And Shouldn't)
Here's where most AI lead generation setups go wrong. People scrape 10,000 leads and dump them all into an outreach sequence. This is insane. Maybe 20–30% of those leads actually fit your ICP well enough to be worth contacting.
Scoring is where AI earns its keep. You're taking each lead and running it through a model that predicts how likely they are to convert. This is the difference between a 2% reply rate and a 12% reply rate.
The simple version uses an LLM as a scoring engine. You feed it the lead data and your ICP definition, and it returns a score with reasoning.
import openai
def score_lead(lead_data, icp_description):
prompt = f"""Score this lead from 1-10 based on how well they match
our ideal customer profile. Return JSON with 'score' and 'reasoning'.
ICP: {icp_description}
Lead:
- Name: {lead_data['name']}
- Title: {lead_data['title']}
- Company: {lead_data['company']}
- Company Size: {lead_data.get('company_size', 'Unknown')}
- Industry: {lead_data.get('industry', 'Unknown')}
- Funding: {lead_data.get('funding', 'Unknown')}
Score 8-10: Perfect ICP fit, decision-maker, right company stage
Score 5-7: Partial fit, may need nurturing
Score 1-4: Poor fit, skip
Return only valid JSON."""
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
response_format={"type": "json_object"},
temperature=0.1
)
return json.loads(response.choices[0].message.content)
The more sophisticated version combines the LLM score with a traditional ML model trained on your historical CRM data. If you've closed 200+ deals, you have enough data to train a simple model:
from sklearn.ensemble import GradientBoostingClassifier
import pandas as pd
# Load your CRM export with won/lost outcomes
df = pd.read_csv("crm_deals.csv")
features = ['company_size_bucket', 'industry_score', 'title_seniority',
'funding_stage', 'tech_stack_overlap']
X = df[features]
y = df['converted'] # 1 = closed won, 0 = lost/no response
model = GradientBoostingClassifier(n_estimators=200, max_depth=4)
model.fit(X, y)
# Score new leads
def ml_score(lead_features):
return model.predict_proba([lead_features])[0][1]
A blended approach works best. Something like:
Final Score = 0.4 × LLM intent score + 0.3 × ML propensity score + 0.3 × engagement signals
According to Apollo's 2024 benchmarks, scored leads convert at 20–40% versus 5–10% for unscored ones. That's a 3–5x improvement just from not emailing everyone with a pulse. Gartner reports 70–85% time savings on qualification when AI scoring is implemented properly.
Only pass leads scoring 7+ to your outreach stage. Everything else goes into a nurture bucket or gets discarded.
Stage 3: Outreach — Personalized at Scale
This is where the magic becomes visible. You're taking your scored, enriched leads and sending them outreach that feels handwritten but runs on autopilot.
Two tools dominate here:
Instantly — Best for pure cold email. AI content optimizer, unlimited email accounts, built-in warmup, A/B testing. Their benchmarks show 45–65% open rates and 5–12% reply rates for well-targeted campaigns. One lead gen agency hit 28% reply rates at peak.
Smartlead — Similar features, slightly better for multi-channel (email + LinkedIn). Typical results: 40–60% open rates, 3–8% reply rates. Has AI reply detection so your agent knows when to hand off to a human.
The secret sauce is the personalization layer. You use your LLM to generate a unique icebreaker for each lead based on their scraped data:
def generate_outreach(lead, company_research):
prompt = f"""Write a cold email to {lead['name']}, {lead['title']}
at {lead['company']}.
About their company: {company_research}
Our product: [YOUR ONE-LINE PITCH]
Rules:
- First line must reference something specific about them or their company
- Under 100 words total
- One clear CTA (book a 15-min call)
- No buzzwords, no "I hope this finds you well"
- Tone: direct, peer-to-peer, slightly casual
- Sound like a human, not a marketing team
Write only the email body. No subject line."""
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
temperature=0.8 # Higher for variety
)
return response.choices[0].message.content
Then push it to Instantly via their API:
import requests
def add_to_campaign(lead, email_body):
requests.post("https://api.instantly.ai/api/v1/lead/add", json={
"api_key": "YOUR_INSTANTLY_KEY",
"campaign_id": "YOUR_CAMPAIGN_ID",
"email": lead["email"],
"first_name": lead["name"].split()[0],
"custom_variables": {
"icebreaker": email_body
}
})
In your Instantly campaign template, you'd use {{icebreaker}} as the email body, so each lead gets their AI-generated personalized version.
Wiring It All Together: The Full Agent
Here's where it gets fun. Instead of running these three stages manually, you orchestrate them into a single autonomous agent. CrewAI is the easiest framework for this if you want multi-agent orchestration. n8n works great if you prefer a visual workflow builder.
Here's the simplified CrewAI version:
from crewai import Agent, Task, Crew
scraper = Agent(
role="Lead Researcher",
goal="Find 200 leads matching our ICP daily",
tools=[apify_scraper_tool, apollo_enrichment_tool],
llm="gpt-4o"
)
scorer = Agent(
role="Lead Analyst",
goal="Score and qualify leads, passing only 7+ to outreach",
tools=[scoring_tool, crm_lookup_tool],
llm="gpt-4o"
)
writer = Agent(
role="Outreach Specialist",
goal="Write personalized cold emails and add to campaign",
tools=[email_writer_tool, instantly_api_tool],
llm="gpt-4o"
)
# Define tasks and create the crew
pipeline = Crew(
agents=[scraper, scorer, writer],
tasks=[scrape_task, score_task, outreach_task],
verbose=True
)
pipeline.kickoff()
Set this to run daily via a cron job or scheduler. Every morning, your agent wakes up, scrapes new leads, scores them, writes personalized emails, and queues them for sending. You review the output for 15 minutes over coffee. That's it.
The Numbers You Can Actually Expect
Let me ground this in reality with numbers from real implementations, not vendor fantasy land:
| Metric | Manual SDR | AI Agent Pipeline |
|---|---|---|
| Leads sourced/week | 100–200 | 1,000–5,000 |
| Time spent/week | 20+ hours | 2–3 hours (review only) |
| Cost per qualified lead | $50–$150 | $10–$25 |
| Reply rate | 1–3% | 5–12% |
| Meetings booked/week | 5–10 | 30–50+ |
| Monthly stack cost | $5K–$7K (salary) | $200–$500 |
These aren't hypothetical. The indie hacker case study from Reddit (u/leadgenbot) ran an n8n + Bright Data + LangChain + Instantly stack and generated 300 qualified leads per month at a 10% close rate, producing $20K/month in revenue. Fully autonomous. CPL: $15.
A B2B agency using Bright Data datasets with custom scoring and Instantly hit 8.7% reply rates (versus 2% from their manual process), booking 1,200 meetings per year at $22 CPL. They reduced campaign management from 20 hours to 2 hours per week.
An e-commerce brand running Apify + Apollo scoring + Smartlead scraped 10,000 leads, scored the top 25%, and achieved 4.5% conversion to actual sales—$1.2M in revenue at a 5x ROI.
Where People Screw This Up
A few landmines to avoid, because I've watched people step on all of them:
Skipping warmup. If you spin up 10 new email domains and blast 500 emails on day one, you'll land in spam instantly. Warm up your domains for 2–3 weeks minimum. Instantly and Smartlead both have built-in warmup tools. Use them.
Not testing ICP definitions. Your first ICP definition will be wrong. Run small batches of 100 leads, measure reply rates, adjust your scoring criteria, and iterate. You're looking for 20%+ reply rates on your best segments. If you're below 5%, your targeting is off.
Over-automating without review. The agent should draft; you should approve (at least initially). Read the first 50 emails your AI writes. You'll catch weird patterns—maybe it's being too aggressive, maybe it's hallucinating company details. Set guardrails, then loosen them as you build confidence.
Ignoring deliverability. Use verified emails only. Set up SPF, DKIM, and DMARC on your sending domains. Keep daily send volume under 50 per mailbox. Rotate mailboxes. This stuff isn't glamorous but it's what determines whether your emails reach inboxes.
Your Stack and Monthly Budget
Here's what I'd recommend for a starting setup:
| Tool | Purpose | Monthly Cost |
|---|---|---|
| Apify | Scraping | $49 (Starter) |
| Apollo.io | Email enrichment | Free (10K credits) |
| OpenAI API | Scoring + email writing | $30–$50 |
| Instantly | Email sending + warmup | $77 (Growth) |
| n8n or CrewAI | Orchestration | Free (self-hosted) |
| Total | $156–$176/month |
Under $200/month for a pipeline that can book 50 demos a week. Compare that to a single SDR's salary. The economics are not subtle.
What to Do Next
Stop reading and start building. Here's your sequence:
This week: Sign up for Apify (free trial) and Instantly (14-day trial). Scrape 500 leads matching your ICP. Enrich with Apollo.
Next week: Build your scoring prompt. Score all 500 leads. Take the top 100 (score 7+). Write personalized outreach using GPT-4o. Load into Instantly.
Week three: Measure reply rates. If above 5%, scale up. If below, adjust your ICP definition and email copy. Test new segments.
Week four: Automate the pipeline with n8n or CrewAI. Set it to run daily. Shift your time from doing outreach to reviewing and optimizing it.
You don't need to build the perfect system on day one. You need a system that runs, generates data, and improves. The AI handles the volume. You handle the judgment. That division of labor is what makes this work.
The founders who figure this out now are going to have an absurd advantage over the ones who are still manually prospecting in 2026. Don't be the second group.