How to Build a Lead Generation Pipeline with Codex

Lead generation is a structured, repeatable process — which makes it a good fit for an agent. With AgentPatch connected, Codex CLI can find businesses through Maps, research them with Search, and send outreach via email, all in one terminal session.

Why This Matters

Building a lead gen tool means testing it with real data. You need to verify that the discovery step returns useful results, that the research step surfaces actionable signals, and that the email step produces output that actually makes sense to send. Mocked data won’t tell you whether the pipeline works.

Codex can run the actual pipeline during development — finding real prospects, producing real drafts — so you know what you’re building handles the real cases.

Setup

Add AgentPatch to ~/.codex/config.toml:

[mcp_servers.agentpatch]
url = "https://agentpatch.ai/mcp"
bearer_token_env_var = "AGENTPATCH_API_KEY"

Then set your API key:

export AGENTPATCH_API_KEY=your_api_key

Replace your_api_key with your actual key from the AgentPatch dashboard. Codex discovers all AgentPatch tools automatically on next start.

Example

You’re building a lead gen CLI tool and want to run a real end-to-end test before writing the abstraction layer. You tell Codex:

“Run a live test of the prospect pipeline. Find dental offices in Atlanta, check their online presence, and draft outreach emails. Don’t send yet — just output everything so I can see what the data looks like.”

Codex runs it:

Searching Google Maps for "dental office Atlanta GA"...

Found: 12 results. Filtering for smaller practices (fewer than 100 reviews):

1. Midtown Dental Arts — 4.3★, 38 reviews
2. Peachtree Family Dentistry — 4.1★, 54 reviews
3. Grant Park Dental — 4.5★, 29 reviews

Searching Google for each practice's web presence...

Midtown Dental Arts: Website found (WordPress, last updated 2023, no blog).
Peachtree Family Dentistry: Outdated Flash-era site design, no mobile version.
Grant Park Dental: No website found, Google Business profile only.

Drafting outreach emails...

Draft 1 — Midtown Dental Arts:
Subject: Midtown Dental Arts website — quick thought
Hi [office manager], noticed your WordPress site hasn't been updated in a while...

Draft 2 — Peachtree Family Dentistry:
[...]

Draft 3 — Grant Park Dental:
[...]

Pipeline output complete. Here's the data shape I'd suggest for the LeadResult type:

interface LeadResult {
  businessName: string;
  rating: number;
  reviewCount: number;
  webPresence: 'none' | 'outdated' | 'present';
  emailDraft: string;
}

Codex ran the pipeline, showed the full output, and derived the data type you need for the abstraction layer. Real data, no mocking needed.

Wrapping Up

With AgentPatch connected, Codex can handle the full lead gen workflow — discovery, research, outreach — directly in the terminal. Maps, Search, and Email are three tools; the same connection also unlocks news, trends, image generation, and everything else on the marketplace. See it all at agentpatch.ai.