Get AI summaries of any video or article — Sign up free
Build Anything with CrewAI, Here’s How thumbnail

Build Anything with CrewAI, Here’s How

David Ondrej·
5 min read

Based on David Ondrej's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

CrewAI can orchestrate a multi-step lead pipeline: generate search queries, search the web, scrape pages, discover about/contact URLs, and extract contact fields.

Briefing

CrewAI is presented as a fast way to build multi-step AI “agents” that can generate lead-targeting search queries, search the web, scrape relevant pages, and extract contact details—without requiring the viewer to write everything from scratch. The practical payoff is a lead-generation pipeline that can be adapted to any niche, location, and lead volume, turning basic inputs (industry + city + number of leads) into structured contact outputs like email and social profiles.

The build starts in Google Colab, where Python runs in notebook cells. After installing CrewAI and connecting to Anthropic’s Claude models via an API key, the workflow uses Claude 3.5 Sonnet (with notes about model/token settings and cheaper alternatives). Two Claude client instances are created: one “consistent” (temperature set low) for predictable outputs, and one “creative” (higher temperature) for generating varied phrasing. This split matters because the pipeline needs both reliable formatting and diverse search-query ideas.

The first CrewAI agent, dubbed a “variation agent,” takes a niche and location and produces 10 distinct, concise search queries intended to surface business leads. A second step wraps that agent into a Crew, then “kickoffs” execution so the generated queries appear as a clean list. The transcript emphasizes output control—no extra text, no quotation marks, and one query per line—so downstream steps can parse results reliably.

Next, the pipeline adds a web-search agent using Serper (via CrewAI tools). The search agent receives the generated queries and returns a list of websites. The build then highlights a key limitation: asking the model to hit a large lead count in one go can cause early stopping or counting errors, since LLMs struggle with strict numeric targets. The suggested fix is structural: use loops outside the agent (and deduplicate) so the system keeps searching until the desired number of qualifying leads is reached.

For scraping, the workflow installs Firecrawl and uses it to convert websites into LLM-ready markdown. After selecting a target site from the search results, Firecrawl scrapes the homepage content (truncated for readability), then a new CrewAI agent analyzes that homepage to find URLs for “about” and “contact” pages. Those pages are scraped as well, and the combined scraped text is fed into a final Anthropic call with a tight prompt instructing the model to extract email, Twitter, and LinkedIn—outputting “none” when fields aren’t found.

The result is a working end-to-end lead extractor: search → scrape → page discovery → contact extraction. The transcript closes by outlining concrete upgrades for production quality: save results to CSV, add personalized unique fields per business, run search and scraping in loops to reach exact lead counts, avoid counting leads with missing contact info, deduplicate websites, and refactor into functions so the whole process can run in a single cell. The overall message is that CrewAI plus purpose-built tools (Serper, Firecrawl, Anthropic) can assemble a usable lead engine quickly, while code-based loops and validation handle the parts where LLMs are least reliable.

Cornell Notes

CrewAI is used to build an end-to-end lead-generation pipeline from simple inputs: niche, location, and desired lead count. A “variation agent” generates 10 optimized search queries, then a “web search agent” uses Serper to find candidate websites. Firecrawl scrapes the homepage, and another agent locates “about” and “contact” page URLs so the scraper can pull the right content. Finally, an Anthropic Claude call extracts email, Twitter, and LinkedIn from the scraped text, using strict formatting rules and “none” when fields are missing. The approach matters because it turns unstructured web content into structured lead data, while also showing why loops and deduplication in code are needed for accurate counting.

How does the pipeline turn a niche and location into search queries that are actually useful for lead finding?

A CrewAI agent (“variation agent”) is configured with a role (“search query specialist”) and an objective to craft high-quality business-lead queries. It uses a “creative” Claude instance (temperature ~0.8) to produce varied phrasing. The task requires exactly 10 concise queries, each on a new line, with strict formatting constraints: no quotation marks, no extra text before/after, and queries must be unique. This makes the output easy to parse and feed directly into the next step.

Why create both “consistent” and “creative” Claude clients in the same project?

The transcript uses two Anthropic Claude instances to control output behavior. The “consistent” client sets temperature to 0, pushing the model toward the most probable tokens for predictable formatting. The “creative” client uses a higher temperature (0.8) to generate diverse search-query variations. That separation helps keep downstream parsing stable (consistent formatting where needed) while still improving coverage (creative query diversity).

What role do Serper and CrewAI tools play after the search-query agent finishes?

Serper is used as the web search backend. The build installs CrewAI tools and instantiates the SerperDev tool using a Serper API key stored in an environment variable. A new CrewAI agent (“web search specialist”) is given the tool and instructed to use the provided search queries to find websites. The key distinction is that this agent is tool-using: it’s not just generating text; it’s retrieving web results based on the query list.

Why does the transcript warn that asking for large lead counts inside a single agent run can fail?

LLMs can stop early or miscount because they’re not reliable at strict numeric targets, especially when the prompt forbids numbered lists or extra formatting. In the demonstration, increasing the desired lead count required rerunning and updating the task prompt; even then, the agent sometimes didn’t reach the target. The recommended fix is architectural: keep counting and validation in code (loops) and have the agent generate/search in smaller batches, deduplicating results until the exact target is met.

How does Firecrawl fit into the scraping and contact-extraction workflow?

Firecrawl is installed and used to scrape websites into LLM-ready markdown. The pipeline first scrapes the homepage (truncated to the first 500 characters for manageable output). Then a CrewAI agent analyzes the homepage content to extract URLs for “about” and “contact” pages (outputting “none” if not found). A function scrapes those pages and combines their content, which is then passed to Claude with a strict extraction prompt to pull email, Twitter, and LinkedIn.

What prompt constraints make the final contact extraction more reliable?

The final Anthropic prompt instructs the model to output fields in a specific format: email, Twitter, LinkedIn, with “none” for any missing field. It also forbids extra text, aiming to keep the output machine-parseable. The transcript notes that while regex could work, a single Claude call over the combined scraped content produced the needed contact fields more effectively in this setup.

Review Questions

  1. Where in the pipeline are output-format constraints most critical, and what specific constraints are used to keep results parseable?
  2. What failure mode appears when trying to reach a large lead count in one agent run, and how does the proposed loop-based fix address it?
  3. How do the “about/contact URL discovery” and “contact field extraction” steps differ in responsibilities and prompting?

Key Points

  1. 1

    CrewAI can orchestrate a multi-step lead pipeline: generate search queries, search the web, scrape pages, discover about/contact URLs, and extract contact fields.

  2. 2

    Splitting Claude usage into “consistent” (temperature 0) and “creative” (higher temperature) helps balance formatting reliability with query diversity.

  3. 3

    Tool-using agents (via CrewAI tools like SerperDev) can retrieve real web results rather than only generating text.

  4. 4

    LLMs are unreliable at strict counting; reaching exact lead targets works better with code-driven loops, deduplication, and validation outside the agent.

  5. 5

    Firecrawl converts websites into LLM-ready markdown, enabling reliable downstream extraction from homepage, about, and contact pages.

  6. 6

    A tight extraction prompt (fixed field order, “none” for missing values, no extra text) improves the chance of structured outputs like email/Twitter/LinkedIn.

  7. 7

    Turning the notebook into functions and CSV outputs is the next step toward making the pipeline reusable for real client delivery.

Highlights

The build uses two Claude modes—temperature 0 for consistency and temperature 0.8 for creative query variation—so the system can both diversify search coverage and keep outputs machine-friendly.
A key reliability lesson: asking an agent to hit large numeric targets in one shot can lead to early stopping or miscounting; loops and deduplication in code are the practical fix.
Firecrawl scraping plus an “about/contact URL discovery” agent lets the pipeline find contact info even when it’s not on the homepage.
The final contact extraction is done with a single Claude call over combined scraped content, using strict formatting rules to output email, Twitter, and LinkedIn (or “none”).

Topics

Mentioned