🔥 0
0
Lesson 8 of 10 22 min +200 XP

Competitor Analysis Agent Crew

Knowing what competitors are doing - and more importantly, why - is essential for e-commerce success. But manually tracking multiple competitors across pricing, products, marketing, and customer sentiment is impossible at scale.

Let's build a Competitor Analysis Crew that continuously monitors and analyzes the competitive landscape.

The Competitive Intelligence Challenge

THE CHALLENGE

  • 10+ competitors to track
  • Daily price changes
  • New product launches missed
  • Marketing campaigns unnoticed
  • Slow to respond to threats

WITH CREWAI

  • Automated monitoring 24/7
  • Real-time price alerts
  • Product launch detection
  • Marketing activity tracking
  • Actionable recommendations

Competitor Analysis Crew Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                  COMPETITOR ANALYSIS CREW                           │
│                                                                     │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐              │
│  │    Price     │  │   Product    │  │  Marketing   │              │
│  │   Tracker    │  │   Scout      │  │  Monitor     │              │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘              │
│         │                 │                 │                       │
│         │     ┌───────────┴───────────┐     │                       │
│         │     │                       │     │                       │
│         │     │  ┌──────────────┐     │     │                       │
│         │     │  │   Review     │     │     │                       │
│         │     │  │   Analyst    │     │     │                       │
│         │     │  └──────┬───────┘     │     │                       │
│         │     │         │             │     │                       │
│         └─────┴─────────┼─────────────┴─────┘                       │
│                         ▼                                           │
│                ┌──────────────────┐                                 │
│                │    Strategic     │                                 │
│                │    Synthesizer   │                                 │
│                └──────────────────┘                                 │
└─────────────────────────────────────────────────────────────────────┘

Complete Implementation

Step 1: Competitive Intelligence Tools

from crewai import Agent, Task, Crew, Process
from crewai.tools import tool
from crewai_tools import SerperDevTool, ScrapeWebsiteTool
from typing import List, Dict
from datetime import datetime, timedelta
import json

@tool("Competitor Price Tracker")
def track_competitor_prices(product_category: str) -> str:
    """
    Tracks competitor pricing for a product category.

    Args:
        product_category: Product category to monitor

    Returns:
        JSON with competitor prices, changes, and trends.
    """
    price_data = {
        "category": product_category,
        "snapshot_date": "2025-03-20",
        "our_price": 129.99,
        "competitors": [
            {
                "name": "Nike",
                "product": "Air Zoom Pegasus 41",
                "current_price": 139.99,
                "previous_price": 139.99,
                "change": 0,
                "change_type": "stable",
                "url": "https://nike.com/pegasus-41",
                "in_stock": True,
                "promo_active": False
            },
            {
                "name": "Adidas",
                "product": "Ultraboost Light",
                "current_price": 169.99,
                "previous_price": 189.99,
                "change": -20.00,
                "change_type": "drop",
                "url": "https://adidas.com/ultraboost-light",
                "in_stock": True,
                "promo_active": True,
                "promo_details": "Spring Sale - 20% off"
            },
            {
                "name": "Brooks",
                "product": "Ghost 15",
                "current_price": 139.95,
                "previous_price": 139.95,
                "change": 0,
                "change_type": "stable",
                "url": "https://brooksrunning.com/ghost-15",
                "in_stock": True,
                "promo_active": False
            },
            {
                "name": "ASICS",
                "product": "Gel-Nimbus 25",
                "current_price": 159.95,
                "previous_price": 159.95,
                "change": 0,
                "change_type": "stable",
                "url": "https://asics.com/nimbus-25",
                "in_stock": False,
                "restock_date": "2025-03-25"
            },
            {
                "name": "New Balance",
                "product": "Fresh Foam 1080v12",
                "current_price": 164.99,
                "previous_price": 164.99,
                "change": 0,
                "change_type": "stable",
                "url": "https://newbalance.com/1080v12",
                "in_stock": True,
                "promo_active": False
            }
        ],
        "market_analysis": {
            "lowest_price": 129.99,
            "highest_price": 169.99,
            "average_price": 148.97,
            "our_position": "Price leader (lowest)",
            "significant_changes": [
                "Adidas dropped $20 - Spring Sale promotion"
            ]
        }
    }

    return json.dumps(price_data, indent=2)


@tool("Product Catalog Monitor")
def monitor_competitor_products(competitor: str) -> str:
    """
    Monitors competitor product catalog for new launches and changes.

    Args:
        competitor: Competitor name to monitor

    Returns:
        JSON with new products, discontinued items, and catalog changes.
    """
    catalog_data = {
        "competitor": competitor,
        "monitoring_period": "Last 30 days",
        "new_products": [
            {
                "name": "Nike Pegasus Premium",
                "launch_date": "2025-03-10",
                "category": "Running Shoes",
                "price": 159.99,
                "key_features": [
                    "React X foam",
                    "Air Zoom units",
                    "Premium leather upper"
                ],
                "positioning": "Premium tier, style-conscious runner",
                "initial_reviews": "Limited - 4.2 avg (47 reviews)"
            }
        ],
        "discontinued": [
            {
                "name": "Nike Pegasus 40",
                "discontinued_date": "2025-03-01",
                "replacement": "Pegasus 41",
                "clearance_price": 89.99
            }
        ],
        "significant_updates": [
            {
                "product": "Nike Pegasus 41",
                "change": "Added 2 new colorways",
                "date": "2025-03-15"
            }
        ],
        "inventory_alerts": [
            {
                "product": "Nike Vaporfly 3",
                "status": "Low stock multiple sizes",
                "implication": "Possible supply constraint or high demand"
            }
        ]
    }

    return json.dumps(catalog_data, indent=2)


@tool("Competitor Review Analyzer")
def analyze_competitor_reviews(competitor: str, product: str) -> str:
    """
    Analyzes competitor product reviews for insights.

    Args:
        competitor: Competitor name
        product: Product name to analyze

    Returns:
        JSON with review sentiment, common complaints, and opportunities.
    """
    review_analysis = {
        "competitor": competitor,
        "product": product,
        "total_reviews": 2847,
        "average_rating": 4.3,
        "rating_trend": "Declining (-0.2 last 30 days)",
        "sentiment_breakdown": {
            "positive": "68%",
            "neutral": "18%",
            "negative": "14%"
        },
        "top_praises": [
            {"theme": "Responsiveness", "frequency": 342, "sample": "The bounce back is incredible"},
            {"theme": "Durability", "frequency": 287, "sample": "Still going strong after 500 miles"},
            {"theme": "Style options", "frequency": 198, "sample": "Love all the colorways"}
        ],
        "top_complaints": [
            {"theme": "Break-in period", "frequency": 156, "sample": "Took 2 weeks to feel comfortable"},
            {"theme": "Narrow fit", "frequency": 134, "sample": "Too tight for wide feet"},
            {"theme": "Price increase", "frequency": 89, "sample": "Not worth $140, old version was better value"},
            {"theme": "Durability regression", "frequency": 67, "sample": "Wore out faster than previous model"}
        ],
        "opportunities_identified": [
            "Customers want immediate comfort (no break-in)",
            "Wide foot options underserved",
            "Value perception declining at higher price points",
            "Quality concerns emerging in latest version"
        ],
        "competitive_insights": [
            "Consider highlighting 'comfortable from first step' messaging",
            "Wide size options could capture frustrated Nike customers",
            "Price point below $140 differentiates on value"
        ]
    }

    return json.dumps(review_analysis, indent=2)


@tool("Marketing Campaign Tracker")
def track_competitor_marketing(competitor: str) -> str:
    """
    Tracks competitor marketing activities.

    Args:
        competitor: Competitor name to monitor

    Returns:
        JSON with active campaigns, ad spend estimates, and messaging.
    """
    marketing_data = {
        "competitor": competitor,
        "monitoring_period": "Last 14 days",
        "active_campaigns": [
            {
                "campaign": "Spring Running Sale",
                "channels": ["Facebook", "Instagram", "Google", "Email"],
                "start_date": "2025-03-15",
                "offer": "20% off running shoes",
                "estimated_spend": "$50,000-75,000/week",
                "messaging_theme": "Fresh start for spring",
                "target_audience": "Running enthusiasts, 25-44",
                "creative_formats": ["Video (15s)", "Carousel", "Static"]
            }
        ],
        "social_activity": {
            "instagram": {
                "posts_per_week": 7,
                "avg_engagement": "3.2%",
                "follower_growth": "+2.1%",
                "top_content": "Athlete testimonials, race day content"
            },
            "tiktok": {
                "posts_per_week": 5,
                "avg_views": "45K",
                "trending_content": "Running transformation challenges"
            }
        },
        "email_activity": {
            "frequency": "2-3 per week",
            "recent_subjects": [
                "Spring into savings: 20% off starts now",
                "Your running goals deserve new gear",
                "Last chance: Spring Sale ends Sunday"
            ],
            "key_offers": ["20% off", "Free shipping", "Bonus gift with purchase"]
        },
        "influencer_partnerships": [
            {
                "influencer": "@marathonrunner",
                "followers": "450K",
                "content_type": "Product review, race content",
                "estimated_value": "$15,000-20,000"
            }
        ],
        "strategic_observations": [
            "Heavy investment in spring campaign - defensive move?",
            "Increased influencer spend suggests brand building priority",
            "Email frequency up - may indicate inventory clearing"
        ]
    }

    return json.dumps(marketing_data, indent=2)


# Web search tool for real-time competitor news
search_tool = SerperDevTool()

Step 2: Define Intelligence Agents

# Agent 1: Price Intelligence Analyst
price_tracker = Agent(
    role="Competitive Price Intelligence Analyst",

    goal="Monitor competitor pricing in real-time and identify "
         "pricing opportunities and threats",

    backstory="""You are a pricing intelligence specialist who has
    tracked pricing for major e-commerce companies. You understand
    that pricing is dynamic warfare.

    Your expertise:
    - Identifying price patterns and cycles
    - Predicting promotional periods
    - Assessing price move intentions (strategic vs tactical)
    - Recommending response strategies

    You know that the right response to a competitor price change
    depends on context - not every drop needs matching.""",

    tools=[track_competitor_prices],
    verbose=True
)


# Agent 2: Product Intelligence Scout
product_scout = Agent(
    role="Competitive Product Intelligence Scout",

    goal="Monitor competitor product catalogs for launches, "
         "discontinuations, and strategic shifts",

    backstory="""You are a product intelligence analyst who tracks
    competitor product strategies. You've predicted major launches
    6 months before public announcement.

    Your focus:
    - New product detection and analysis
    - Feature comparison and positioning
    - Discontinuation signals
    - Supply and inventory indicators

    You connect product moves to competitive strategy.""",

    tools=[monitor_competitor_products, search_tool],
    verbose=True
)


# Agent 3: Customer Sentiment Analyst
review_analyst = Agent(
    role="Competitor Customer Sentiment Analyst",

    goal="Analyze competitor customer feedback to identify "
         "weaknesses and unmet needs we can exploit",

    backstory="""You are a voice-of-customer specialist who finds
    gold in competitor reviews. You've identified product opportunities
    worth millions by reading what customers really say.

    Your approach:
    - Look beyond ratings to specific complaints
    - Identify patterns across reviews
    - Find unmet needs competitors ignore
    - Translate complaints into our opportunities

    Every competitor weakness is our potential strength.""",

    tools=[analyze_competitor_reviews],
    verbose=True
)


# Agent 4: Marketing Intelligence Analyst
marketing_monitor = Agent(
    role="Competitive Marketing Intelligence Analyst",

    goal="Track competitor marketing activities and extract "
         "strategic insights about their priorities and tactics",

    backstory="""You are a competitive marketing analyst who decodes
    competitor strategies from their marketing activities. You've
    predicted major competitive moves from ad pattern changes.

    Your analysis covers:
    - Campaign themes and messaging evolution
    - Channel and spend pattern shifts
    - Promotional calendar prediction
    - Influencer and partnership tracking

    Marketing spend tells you what competitors really prioritize.""",

    tools=[track_competitor_marketing, search_tool],
    verbose=True
)


# Agent 5: Strategic Synthesizer
strategic_synthesizer = Agent(
    role="Competitive Strategy Synthesizer",

    goal="Synthesize all competitive intelligence into actionable "
         "strategic recommendations for leadership",

    backstory="""You are a strategy consultant who transforms data
    into decisions. You've advised Fortune 500 companies on
    competitive strategy.

    Your deliverables:
    - Executive-ready intelligence briefs
    - Prioritized threat and opportunity assessment
    - Specific, actionable recommendations
    - Risk-adjusted response options

    You turn information into competitive advantage.""",

    verbose=True
)

Step 3: Define the Intelligence Workflow

# Task 1: Price Intelligence
price_task = Task(
    description="""
    Analyze the competitive pricing landscape for: {product_category}

    Your analysis should cover:
    1. Current competitor prices vs. our price
    2. Recent price changes (last 7 days)
    3. Active promotions and their likely duration
    4. Pricing position assessment (are we premium, value, parity?)
    5. Price war risk assessment

    Flag any significant changes requiring immediate attention.
    """,

    expected_output="""
    Price intelligence report:
    - Competitor price comparison table
    - Significant price changes with analysis
    - Promotional activity summary
    - Our competitive position assessment
    - Recommended pricing response (if any)
    """,

    agent=price_tracker
)


# Task 2: Product Intelligence
product_task = Task(
    description="""
    Analyze competitor product activities for our category.

    Focus on:
    1. New product launches in the last 30 days
    2. Products being discontinued or clearanced
    3. Feature updates or improvements
    4. Inventory status signals (stockouts, overstocks)
    5. Upcoming launches (rumors, announcements)

    Assess implications for our product strategy.
    """,

    expected_output="""
    Product intelligence report:
    - New launches with feature analysis
    - Discontinuation signals
    - Competitive feature comparison
    - Inventory status insights
    - Strategic implications for our roadmap
    """,

    agent=product_scout
)


# Task 3: Customer Sentiment Analysis
sentiment_task = Task(
    description="""
    Analyze competitor customer reviews to find opportunities.

    For each major competitor, identify:
    1. Overall customer sentiment trend
    2. Top 3 complaints we could address
    3. Unmet needs customers express
    4. Features customers love that we should consider
    5. Quality or service issues to exploit

    Translate findings into competitive opportunities.
    """,

    expected_output="""
    Competitor sentiment report:
    - Per-competitor sentiment summary
    - Top complaints and our opportunity
    - Unmet needs we could serve
    - Competitive messaging opportunities
    - Product improvement suggestions
    """,

    agent=review_analyst
)


# Task 4: Marketing Intelligence
marketing_task = Task(
    description="""
    Analyze competitor marketing activities and campaigns.

    Track:
    1. Active campaigns and their messaging
    2. Channel mix and estimated spend
    3. Promotional offers and timing
    4. Social media activity and engagement
    5. Influencer partnerships

    Decode what their marketing tells us about strategy.
    """,

    expected_output="""
    Marketing intelligence report:
    - Active campaign summary
    - Messaging theme analysis
    - Channel and spend assessment
    - Social media performance
    - Strategic implications of marketing shifts
    """,

    agent=marketing_monitor
)


# Task 5: Strategic Synthesis
synthesis_task = Task(
    description="""
    Synthesize all competitive intelligence into an actionable
    strategic brief for leadership.

    Your brief should include:
    1. EXECUTIVE SUMMARY: 3 key takeaways
    2. IMMEDIATE THREATS: Issues requiring action this week
    3. EMERGING OPPORTUNITIES: Windows to exploit
    4. STRATEGIC RECOMMENDATIONS: Prioritized actions
    5. WATCH LIST: Items to monitor closely

    Be specific and actionable. Leadership needs decisions, not data.
    """,

    expected_output="""
    Strategic competitive intelligence brief:
    - Executive summary (3 bullet points)
    - Threat assessment with urgency levels
    - Opportunity assessment with potential value
    - 5 prioritized recommendations
    - Watch list for next reporting period
    """,

    agent=strategic_synthesizer,
    context=[price_task, product_task, sentiment_task, marketing_task]
)

Step 4: Assemble the Intelligence Crew

# Create the Competitor Analysis Crew
competitor_crew = Crew(
    agents=[
        price_tracker,
        product_scout,
        review_analyst,
        marketing_monitor,
        strategic_synthesizer
    ],
    tasks=[
        price_task,
        product_task,
        sentiment_task,
        marketing_task,
        synthesis_task
    ],
    process=Process.sequential,
    verbose=True
)


def run_competitive_analysis(product_category: str) -> str:
    """Run comprehensive competitive analysis."""
    result = competitor_crew.kickoff(
        inputs={"product_category": product_category}
    )
    return result


# Run the competitor analysis crew
if __name__ == "__main__":
    report = run_competitive_analysis("running_shoes")
    print("\n" + "="*60)
    print("COMPETITIVE INTELLIGENCE BRIEF")
    print("="*60)
    print(report)

Sample Strategic Brief Output

Competitive Intelligence Brief: Running Shoes

Executive Summary
  • Adidas launched aggressive spring sale (-$20), likely clearing inventory before new model
  • Nike's new Pegasus Premium targets style-conscious segment we've ignored
  • Competitor review analysis reveals "immediate comfort" as underserved need
Immediate Threats
  • HIGH: Adidas at $169.99 now competes directly on value
  • MEDIUM: Nike premium launch may shift market expectations
Opportunities
  • HIGH: Wide-foot segment underserved (134 complaints)
  • MEDIUM: "No break-in" messaging differentiator
Recommended Actions
  1. HOLD pricing - Our $129.99 remains competitive; don't match Adidas promo
  2. Launch "Comfortable from step one" messaging campaign
  3. Evaluate wide-fit variant for product roadmap (Q3 opportunity)
  4. Monitor Adidas post-sale pricing to assess if permanent or promotional
  5. Track Nike Premium sell-through for premium segment appetite

Automated Monitoring System

Set up continuous competitive monitoring:

import schedule

def daily_price_check():
    """Quick daily price monitoring."""
    price_result = price_tracker.execute_task(price_task)
    if "significant" in price_result.lower() or "alert" in price_result.lower():
        send_alert("Price Alert", price_result)

def weekly_full_analysis():
    """Comprehensive weekly competitive analysis."""
    report = run_competitive_analysis("running_shoes")
    send_to_leadership(report)
    archive_report(report)

# Schedule monitoring
schedule.every().day.at("07:00").do(daily_price_check)
schedule.every().monday.at("09:00").do(weekly_full_analysis)

Key Takeaways

  • Monitor multiple dimensions - Pricing, products, reviews, and marketing together
  • Competitor reviews are goldmines - Their complaints are your opportunities
  • Synthesize into action - Transform data into specific recommendations
  • Don't react automatically - Analyze context before responding to changes
  • Automate monitoring - Daily checks catch threats early

Next up: Orchestration Patterns - Learn when to use sequential vs hierarchical crews for different workflows.

🧠 Quick Quiz

Test your understanding of this lesson.

1

What are the key areas the Competitor Analysis Crew should monitor?

2

Why is analyzing competitor customer reviews valuable?

3

What should the crew do when they detect a significant competitor price drop?