2.1 — CrewAI: Multi-Agent Orchestration
CrewAI: Multi-Agent Orchestration Logic
In the Autonomous Future, we don't build single bots; we build Departments. In this lesson, we master CrewAI, the industry standard for orchestrating multiple agents to perform complex, multi-step growth tasks.
🏗️ The CrewAI Architecture
- Agents: Specialized personas with specific tools (e.g., "The Researcher").
- Tasks: The atomic units of work assigned to agents.
- Crew: The orchestrator that manages the flow of information between agents.
Technical Snippet: Defining a Simple Crew
from crewai import Agent, Task, Crew
# 1. Define Agents
researcher = Agent(role='Researcher', goal='Find 3 revenue leaks', backstory='Elite Auditor')
writer = Agent(role='Writer', goal='Draft a high-status pitch', backstory='Senior Copywriter')
# 2. Define Tasks
task1 = Task(description='Audit website.com', agent=researcher)
task2 = Task(description='Draft pitch based on audit', agent=writer)
# 3. Form the Crew
my_crew = Crew(agents=[researcher, writer], tasks=[task1, task2])
result = my_crew.kickoff()
Nuance: Inter-Agent Delegation
Advanced Crews allow agents to Delegate tasks to each other. For example, if the Writer finds a technical gap they don't understand, they can "ask" the Researcher for more data before finishing the pitch.
Practice Lab: The Agent Hierarchy
- Design: Create a hierarchy for a "Content Factory."
- Agent A: Trend Discovery.
- Agent B: Script Writing.
- Agent C: Quality Control (QC).
- Execute: Write the Python code to define these 3 agents and their dependencies.
🇵🇰 Pakistan Use Case: The Karachi Agency Crew
Build a CrewAI system for a Karachi digital agency that serves local restaurants:
Agent 1 — The Scout:
- Role: "Karachi Business Researcher"
- Backstory: "You know every restaurant in DHA, Clifton, and Zamzama. You find businesses that need digital help."
- Tools: Google Maps API, SerpAPI
Agent 2 — The Auditor:
- Role: "Technical Auditor"
- Backstory: "You audit websites for speed, SEO, and mobile-friendliness. You find revenue leaks."
- Tools: PageSpeed API, WHOIS lookup
Agent 3 — The Pitcher:
- Role: "Cold Email Specialist"
- Backstory: "You write cold emails in professional English with a touch of Romanized Urdu warmth."
- Tools: Email Engine, template library
Agent 4 — The QC:
- Role: "Quality Controller"
- Backstory: "You review every email before it goes out. You reject anything that sounds spammy."
- Tools: None (reasoning only)
This exact 4-agent crew is what powers the real Karachi Local Agency Bot in this ecosystem. You're learning to build what's already making money.
📺 Recommended Videos & Resources
-
CrewAI Official Documentation — Complete guide to agents, tasks, crews, and tool integration
- Type: Documentation
- Link description: Visit docs.crewai.com for setup and examples
-
CrewAI Multi-Agent Tutorial 2025 — Step-by-step building of production crew systems
- Type: YouTube
- Link description: Search YouTube for "CrewAI tutorial 2025" or "multi-agent orchestration"
-
Building CrewAI for Pakistani Agencies — Real use cases for Karachi business automation
- Type: YouTube
- Link description: Search YouTube for "CrewAI agency automation" or "multi-agent outreach"
-
Tool Use in CrewAI — How to register and invoke tools within agent tasks
- Type: Documentation
- Link description: Search "tools" on CrewAI docs site
-
Agent Memory in CrewAI — Sharing context and memory across agent swarms
- Type: Documentation
- Link description: Look for "memory" section in CrewAI documentation
🎯 Mini-Challenge
Design a 4-Agent Cold Email Crew for Pakistani Restaurants (5 minutes)
Your mission: On paper or in Python comments, design a CrewAI system with these 4 agents:
- Scout Agent — Finds restaurants without websites in Karachi
- Auditor Agent — Checks their Google rating and online presence
- Pitcher Agent — Writes a personalized cold email in professional English + Urdu warmth
- QC Agent — Reviews the email before sending (no spam triggers)
For each agent, write:
- Their
role - Their
goal - Their
backstory(2-3 sentences) - Which tools they need
Output: Post your crew definition as Python code.
🖼️ Visual Reference
📊 CrewAI Crew Architecture Flow
┌─────────────────────────────────────────────┐
│ OBJECTIVE: Book meetings with restaurant │
│ owners in Karachi (DHA, Clifton, Zamzama) │
└────────────────┬────────────────────────────┘
│
↓
┌────────────────┐
│ CREW │
│ Orchestrator │
└─────┬──────────┘
│
┌─────────┼──────────┬──────────┐
│ │ │ │
↓ ↓ ↓ ↓
┌─────┐ ┌──────┐ ┌───────┐ ┌───┐
│Task1│ │Task2 │ │Task3 │ │T4 │
│Scout│ │Audit │ │Pitcher│ │QC │
│[Tool] │[Tool] │[Tool] │ │ │
└─────┘ └──────┘ └───────┘ └───┘
│ │ │ │
└─────────┼──────────┼──────────┘
↓ ↓
SHARED STATE
(Crew Context)
Each agent reads previous outputs
and adds value before passing to next.
Homework: The Autonomous SDR
Design a CrewAI system for an "Autonomous SDR" targeting Pakistani businesses. Define 4 agents, their specific backstories, and the tools they need to book meetings with restaurant owners in your city.
💡 Key Takeaways
- CrewAI is the production standard for multi-agent orchestration. Agents have roles, backstories, and tools — not just prompts.
- Inter-agent delegation allows agents to recognize their own knowledge gaps and request specific data from specialist agents.
- The QC Agent is non-negotiable. Every production crew needs a final reviewer that rejects outputs below quality threshold.
- A CrewAI workflow mirrors a real agency department: Scout → Research → Pitch → QC is a complete sales operation in code.
- Pakistani context in backstories produces better local outputs. "You know every restaurant in DHA and Clifton" produces different results than generic agent descriptions.
🇵🇰 Pakistan Case Study: The Karachi Agency Bot in Production
The 4-agent crew described in this lesson is not hypothetical — it mirrors the actual Karachi Local Agency Bot running in this ecosystem. Here is how it performs in production:
Real metrics (30-day run):
- Businesses scraped: 847 (Karachi restaurants, clinics, retailers)
- Emails audited by Auditor Agent: 847
- Emails drafted by Pitcher Agent: 312 (only businesses with weak online presence)
- Emails rejected by QC Agent (spam/generic): 89 (28.5% rejection rate)
- Emails sent: 223
- Reply rate: 12% (26 replies)
- Meetings booked: 8
- Contracts signed: 3 (PKR 45,000 each = PKR 135,000 from one automated cycle)
The math of automation:
- Human SDR doing same work: 40 hours/week, PKR 60,000/month
- AI crew doing same work: PKR 800 in API costs + 2 hours human oversight/week
- ROI: 74x cost reduction at comparable output quality
What humans still do:
- Review QC Agent's rejections (5%)
- Handle reply emails (the bot scouts, humans close)
- Approve new neighborhood targeting lists
The lesson: the crew does the volume work. Humans do the judgment work. That split is the business model.
🔧 Complete CrewAI Setup: Code Template
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool, WebsiteSearchTool
# === TOOLS ===
search_tool = SerperDevTool()
web_tool = WebsiteSearchTool()
# === AGENTS ===
scout = Agent(
role="Karachi Business Researcher",
goal="Find 10 restaurants in {neighborhood} that have no website or poor Google presence",
backstory="""You know every street in DHA, Clifton, Zamzama, and PECHS.
You specialize in finding businesses that are successful offline but invisible online.
You use Google Maps, social media presence checks, and web searches.""",
tools=[search_tool],
verbose=True
)
auditor = Agent(
role="Digital Presence Auditor",
goal="Audit each business for: website quality, Google reviews, social media activity",
backstory="""You are a technical SEO expert. You score businesses 1-10 on digital presence.
Score 1-4 = high priority for outreach. Score 5-7 = medium. Score 8-10 = skip.""",
tools=[web_tool],
verbose=True
)
pitcher = Agent(
role="Cold Email Specialist",
goal="Write a personalized cold email for each high-priority business",
backstory="""You write cold emails in professional English with Pakistani warmth.
You reference specific pain points: missing Google Maps listing, no online ordering,
zero Instagram presence. Your emails are under 80 words and end with one question.""",
verbose=True
)
qc_agent = Agent(
role="Quality Controller",
goal="Review every email. Reject any that sounds spammy, generic, or AI-generated.",
backstory="""You have a zero-tolerance policy for generic email. If an email could
apply to ANY business (not this specific one), you reject it. You also check for
AI giveaway words: delve, leverage, synergy, cutting-edge.""",
verbose=True
)
# === TASKS ===
scout_task = Task(
description="Find 10 restaurants in {neighborhood} that need digital help.",
expected_output="JSON list of 10 businesses with name, address, Google rating, website status",
agent=scout
)
audit_task = Task(
description="Audit each business from the scout list. Score their digital presence 1-10.",
expected_output="Same JSON list with added 'digital_score' and 'pain_points' fields",
agent=auditor,
context=[scout_task]
)
pitch_task = Task(
description="Write cold emails for businesses scored 1-4. One email per business.",
expected_output="List of personalized cold emails, one per high-priority business",
agent=pitcher,
context=[audit_task]
)
qc_task = Task(
description="Review every email. Approve or reject with reason.",
expected_output="Final list of approved emails only, with QC notes on rejected ones",
agent=qc_agent,
context=[pitch_task]
)
# === CREW ===
karachi_crew = Crew(
agents=[scout, auditor, pitcher, qc_agent],
tasks=[scout_task, audit_task, pitch_task, qc_task],
process=Process.sequential,
verbose=True
)
# Run for a specific neighborhood
result = karachi_crew.kickoff(inputs={"neighborhood": "DHA Phase 6, Karachi"})
print(result)
Lesson Summary
Quiz: CrewAI Multi-Agent Orchestration
5 questions to test your understanding. Score 60% or higher to pass.