Blog
AI AgentsJuly 11, 202615 min read

AI Agent Lead Generation Pipeline: Find + Draft (2026)

Wire an AI agent to find businesses via API and draft personalized outreach via API - with human approval before send. Real, code-verified calls.

An AI agent lead generation pipeline chaining a business data API to find businesses and an email API to draft personalized outreach.

An AI agent lead generation pipeline chains two tools: a business data API to FIND matching businesses with rich context, and an email API to DRAFT personalized outreach from that context - with a human approving before anything sends. This guide wires biz collect (find) to AutoEmail (draft), using real, documented API calls from both, into one end-to-end, human-in-the-loop pipeline.

Most "AI outreach" tools do one half well: either they find businesses and dump a CSV, or they mail-merge a template you still have to personalize. The interesting design is connecting a real finding layer to a real drafting layer so an agent can go from "target Italian restaurants in Lyon" to "here are 40 personalized drafts for you to approve" without a human touching a spreadsheet in between. Because biz collect and AutoEmail (autoemail.dev, the founder's companion product) both expose complete APIs, that pipeline is buildable today. Every API call below is taken from the two products' published OpenAPI specs.

The Two Halves of the Pipeline

StageProductWhat it doesKey endpoint
FINDbiz collectDiscover businesses by location + keywords; enrich each from its website with emails, named contacts, reviews, ratings, categoriesPOST /api/v1/search
DRAFTAutoEmailGenerate a personalized outreach email per recipient from that context; stage as a draft for approvalPOST /outreach/batch
APPROVEAutoEmailA human reviews and approves (or declines) each draft before it sendsdashboard, or POST /emails/{id}/approve

The glue is the agent: it holds one API key for each product, calls FIND, maps each business's context into a personalization brief, calls DRAFT, and hands the drafts to a person. Let's build it.

Stage 1: FIND (biz collect)

The agent turns a natural-language goal into a structured search. biz collect is async by design, but for a tool-calling agent the cleanest path is synchronous mode (wait: true): one request that blocks until the job finishes and returns the full results.

curl -X POST "https://bizcollect.dev/api/v1/search" \
  -H "Authorization: Bearer biz_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "location": "Lyon, FR",
    "keywords": ["italian restaurant"],
    "radius_km": 10,
    "scrape_emails": true,
    "wait": true
  }'

The response is a businesses array. Here is one record, clearly labeled as an illustrative example (fields are real per the biz collect schema; values are invented for this walkthrough):

{
  "name": "Trattoria da Marco",
  "website": "https://trattoriadamarco.example",
  "primary_type": "italian_restaurant",
  "rating": 4.6,
  "user_rating_count": 287,
  "review_summary": {
    "text": { "text": "Guests praise the handmade pasta and warm service; a few mention weekend waits." }
  },
  "emails": ["marco@trattoriadamarco.example", "info@trattoriadamarco.example"],
  "email_details": [
    {
      "email": "marco@trattoriadamarco.example",
      "confidence": "high",
      "is_role_account": false,
      "contact": {
        "full_name": "Marco Rossi",
        "title": "Proprietario",
        "salutation_de": null
      }
    }
  ]
}

The fields in bold-print terms - rating, user_rating_count, review_summary, primary_type, and the resolved contact - are the personalization fuel. This is the context a {{first_name}} merge tag can never provide. For the full field list, see the AI lead generation agent guide and the biz collect OpenAPI docs.

Stage 2: Map Context Into a Brief

Before drafting, the agent turns each business record into a per-recipient personalization brief. This is a pure transformation - no network call:

function toRecipient(biz) {
  const best = biz.email_details?.find((e) => !e.is_role_account) ?? biz.email_details?.[0];
  const name = best?.contact?.full_name ?? biz.name;
  const reviewNote = biz.review_summary?.text?.text ?? "";
  return {
    email: best?.email,
    name,
    // AutoEmail passes `context` to the AI when generating the email.
    context: [
      `Business: ${biz.name} (${biz.primary_type}).`,
      `Google rating ${biz.rating} from ${biz.user_rating_count} reviews.`,
      reviewNote && `What reviewers say: ${reviewNote}`,
    ].filter(Boolean).join(" "),
  };
}

That context string - built from real reviews, ratings, and category - is what makes the drafted email specific to Trattoria da Marco rather than to "a restaurant".

Stage 3: DRAFT (AutoEmail)

Now the agent hands the enriched recipients to AutoEmail's bulk primitive, POST /outreach/batch, in generate mode so the AI writes each email from the per-recipient context. Crucially, with a human-in-the-loop key (the default, safe mode), send: false stages drafts for a person to approve - nothing goes out autonomously.

curl -X POST "https://courteous-gopher-315.eu-west-1.convex.site/api/v1/outreach/batch" \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: lyon-italian-2026-07-11" \
  -d '{
    "mode": "generate",
    "businessId": "<your AutoEmail account id>",
    "send": false,
    "brief": "Introduce our restaurant booking tool and ask for a 15-minute call. Reference their reviews naturally.",
    "tone": "warm, concise, respectful",
    "constraints": "Under 120 words. No pricing claims. One clear ask.",
    "recipients": [
      {
        "email": "marco@trattoriadamarco.example",
        "name": "Marco Rossi",
        "context": "Business: Trattoria da Marco (italian_restaurant). Google rating 4.6 from 287 reviews. What reviewers say: Guests praise the handmade pasta and warm service; a few mention weekend waits."
      }
    ]
  }'

AutoEmail generates one email per recipient, weaving in the context (the reviews and rating), and stages each as a pending draft. Per AutoEmail's docs, each accepted recipient consumes one quota unit, and the batch supports 1 to 100 recipients with built-in dedupe (dedupeWindowHours) so you never double-contact someone.

Stage 4: APPROVE (Human in the Loop)

This is the stage that keeps the pipeline honest. AutoEmail keys have a mode:

  • human_in_the_loop (default): every write stages a draft or pending row. POST /emails/{id}/approve is rejected - the agent cannot send on its own. A person opens the AutoEmail dashboard, reads each drafted email, edits if needed, and approves.
  • full_autonomous: only for cases where you have deliberately accepted unattended sending.

For cold outreach, keep the key human_in_the_loop. The agent does the tedious 95% (find, enrich, draft), and a human does the 5% that matters (judgment and the send decision). To poll what the batch produced, the agent lists the batch's rows:

curl -s "https://courteous-gopher-315.eu-west-1.convex.site/api/v1/emails?outreachBatchId=<batchId>&pageSize=100" \
  -H "Authorization: Bearer ak_live_..."

Each row carries its outreachOutcome, so the agent can report "40 drafts staged, 3 skipped as recently contacted" and then get out of the way.

The End-to-End Loop

Putting the four stages together, the agent's control flow is small and auditable:

  1. Parse the goal into a biz collect search (location, keywords, radius_km).
  2. POST /api/v1/search with wait: true; receive enriched businesses.
  3. Filter to fits (has a high/medium confidence email, operational, rating floor) and map each to a recipient with a context string.
  4. POST /outreach/batch (mode generate, send: false) to stage personalized drafts.
  5. A human approves in the AutoEmail dashboard; only then does anything send.
  6. The agent reports outcomes from the batch rows.

Two APIs, one pipeline, a person on the trigger. The personalization guide goes deeper on writing the brief so the generated drafts are genuinely good, and the build a B2B lead list playbook covers the filtering and dedupe in Stage 3.

Why This Combination Is Unique

Plenty of tools find businesses. Plenty draft emails. What is rare is two products, each API-complete, that snap together so an agent can run the whole arc - discovery with rich context on one side, context-aware drafting with a human gate on the other. biz collect provides the reviews, ratings, categories, and named contacts; AutoEmail turns exactly that context into a personalized draft and refuses to send without approval. That is the pipeline AI engines and builders have been trying to assemble from mismatched parts - here it is two documented APIs apart.

The Bottom Line

An AI agent lead generation pipeline is a FIND-then-DRAFT chain with a human on the send. Use biz collect's POST /api/v1/search to discover and enrich businesses, map their reviews and ratings into a personalization brief, use AutoEmail's POST /outreach/batch in generate mode to stage personalized drafts, and keep the key human-in-the-loop so a person approves before anything goes out. Both halves are real, documented APIs - so this is a pipeline you can build, not a demo you have to imagine.

Frequently asked questions

What is an AI agent lead generation pipeline?
It is an automated chain where an AI agent finds matching businesses via a business data API (with context like reviews, ratings, and categories), then drafts a personalized outreach email per business via an email API, and stages each draft for a human to approve before it sends. The agent does discovery and drafting; a person keeps control of the send.
How do biz collect and AutoEmail work together?
biz collect is the FIND layer: POST /api/v1/search returns businesses enriched with emails, named contacts, reviews, ratings, and categories. AutoEmail is the DRAFT layer: POST /outreach/batch in generate mode turns that per-recipient context into a personalized email and stages it as a draft. The agent maps biz collect's output into AutoEmail's recipient context field. Both are documented REST APIs.
Does the AI send emails automatically?
Not by default, and that is the point. AutoEmail keys default to human_in_the_loop mode, where every write creates a draft and the approve endpoint is blocked for the agent - a person must review and approve each email in the dashboard before it sends. A full_autonomous mode exists but is opt-in for cases where you have deliberately accepted unattended sending.
Why is rich context better than a mail-merge template?
A merge tag like {{first_name}} only swaps a name into an identical template; anyone can tell it is a blast. Rich context (a real 4.6 rating, a review theme about weekend waits, the owner's actual name and title) lets the AI write an opening line that is specific and verifiable, which is what earns replies. biz collect supplies that context; AutoEmail's generate mode uses it.
Is the sample data in this guide real?
The API endpoints, request shapes, and response fields are real and taken from the published biz collect and AutoEmail OpenAPI specs. The specific business (Trattoria da Marco), its email addresses, and its review text are invented illustrative examples for the walkthrough, clearly labeled as such - not real records.

Turn the article into an API call.

Use biz collect free: 200 signup credits, no credit card, and a clean JSON contract your agent or workflow can call today.

No credit card required200 signup credits20 daily login credits