What is CrewAI?
Imagine running an e-commerce store where you need to write product descriptions, analyze customer reviews, monitor competitor prices, and create marketing content. That's a lot for one person - or one AI agent.
What if you could build a team of specialized AI agents that work together?That's exactly what CrewAI enables.
SINGLE AGENT APPROACH
- One agent does everything
- Context gets overloaded
- Jack of all trades, master of none
- Hard to debug failures
- Limited specialization
MULTI-AGENT CREW
- Specialized agents per task
- Focused context windows
- Experts in their domain
- Easier to trace and debug
- Collaborative problem-solving
The CrewAI Mental Model
CrewAI is built around four core primitives that mirror how real teams work:
A team member with a role, goal, and backstory. Like a "Product Copywriter" or "Price Analyst".
A specific job to be done. Includes description, expected output, and assigned agent.
Capabilities agents can use - web search, database queries, API calls, file operations.
The team itself - which agents work together, what tasks they do, and how they collaborate.
Why Multi-Agent for E-commerce?
E-commerce operations involve many specialized tasks that benefit from dedicated expertise:
| E-commerce Task | Agent Role | Benefit |
|---|---|---|
| Product Descriptions | Copywriter Agent | SEO-optimized, brand-consistent copy |
| Price Optimization | Pricing Analyst Agent | Data-driven competitive pricing |
| Review Analysis | Sentiment Analyst Agent | Extract insights from feedback |
| Marketing Content | Marketing Strategist Agent | Multi-channel campaign content |
| Competitor Monitoring | Market Research Agent | Stay ahead of market trends |
Setting Up CrewAI
Let's install CrewAI and create your first e-commerce crew.
Installation
# Install CrewAI (requires Python 3.10+)
pip install crewai crewai-tools
# Set your API key (CrewAI supports OpenAI, Anthropic, and more)
export OPENAI_API_KEY="your-api-key"
Your First E-commerce Crew
Here's a simple crew that generates a product description:
from crewai import Agent, Task, Crew
# Define a Product Copywriter agent
copywriter = Agent(
role="E-commerce Product Copywriter",
goal="Write compelling product descriptions that drive sales",
backstory="""You are a senior copywriter at a top e-commerce company.
You specialize in writing product descriptions that are:
- SEO-optimized for search engines
- Emotionally compelling for customers
- Clear about product benefits and features
You have 10 years of experience writing for Amazon, Shopify, and DTC brands.""",
verbose=True
)
# Define a task for the agent
write_description = Task(
description="""Write a product description for:
Product: Wireless Noise-Canceling Headphones
Price: $149.99
Features: 40-hour battery, Bluetooth 5.3, foldable design,
built-in microphone, active noise cancellation
Target audience: Remote workers and commuters
Create a description that highlights benefits, not just features.""",
expected_output="A compelling 150-200 word product description",
agent=copywriter
)
# Create the crew and run it
crew = Crew(
agents=[copywriter],
tasks=[write_description],
verbose=True
)
# Execute the crew
result = crew.kickoff()
print(result)
Understanding the Output
When you run this crew, you'll see:
CrewAI Architecture
Here's how the pieces fit together:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CREW โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ AGENTS โ โ
โ โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ โ
โ โ โCopywriterโ โ Analyst โ โResearcherโ โ โ
โ โ โ Agent โ โ Agent โ โ Agent โ โ โ
โ โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ โ
โ โ โ โ โ โ โ
โ โ โโโโโโผโโโโโโ โโโโโโผโโโโโโ โโโโโโผโโโโโโ โ โ
โ โ โ Tools โ โ Tools โ โ Tools โ โ โ
โ โ โ(Write, โ โ(Database,โ โ(Search, โ โ โ
โ โ โ Format) โ โ Calculateโ โ Scrape) โ โ โ
โ โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ TASKS โ โ
โ โ Task 1 โโโบ Task 2 โโโบ Task 3 (Sequential) โ โ
โ โ or โ โ
โ โ Manager assigns tasks to workers (Hierarchical) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Process Types in CrewAI
CrewAI supports different ways for agents to collaborate:
Tasks run one after another. Agent A's output becomes Agent B's input. Simple and predictable.
Research โ Write โ Review
A manager agent delegates tasks to worker agents. Great for complex, branching workflows.
Manager โ [Workers]
Real E-commerce Example: Product Launch Crew
Here's a more realistic example - a crew that helps launch a new product:
from crewai import Agent, Task, Crew, Process
# Researcher finds market insights
researcher = Agent(
role="Market Research Analyst",
goal="Identify target audience and competitive positioning",
backstory="Expert at analyzing e-commerce trends and customer demographics"
)
# Copywriter creates the listing
copywriter = Agent(
role="Product Copywriter",
goal="Create compelling, SEO-optimized product listings",
backstory="Seasoned e-commerce copywriter with conversion expertise"
)
# Reviewer ensures quality
reviewer = Agent(
role="Content Quality Reviewer",
goal="Ensure accuracy, brand consistency, and SEO best practices",
backstory="Editorial expert who maintains content standards"
)
# Define the workflow
research_task = Task(
description="Research the target market for a new yoga mat product",
expected_output="Market analysis with target demographics and positioning",
agent=researcher
)
writing_task = Task(
description="Write product listing using the research insights",
expected_output="Complete product title, description, and bullet points",
agent=copywriter
)
review_task = Task(
description="Review and polish the product listing",
expected_output="Final approved product listing",
agent=reviewer
)
# Create a sequential crew
product_launch_crew = Crew(
agents=[researcher, copywriter, reviewer],
tasks=[research_task, writing_task, review_task],
process=Process.sequential, # Tasks run in order
verbose=True
)
result = product_launch_crew.kickoff()
Key Takeaways
- CrewAI orchestrates multiple AI agents - Each agent has a role, goal, and backstory
- Four core primitives - Agents, Tasks, Tools, and Crews
- E-commerce is perfect for multi-agent - Many specialized tasks benefit from focused agents
- Process types - Sequential for linear workflows, Hierarchical for complex delegation
Next up: Defining Agent Roles and Goals - How to craft effective agent personas for e-commerce tasks.