PatternsReal-world Examples

Competitor Research Agent

Loading pattern preview

Problems solved

Technical challenges this implementation handles out of the box.
  • Extract competitor site data with Firecrawl map and scrape
  • Analyze positioning, pricing tiers, and feature matrices
  • Detect technologies used on competitor properties
  • Generate sales battle cards from live competitor pages

Use cases

Products and workflows this pattern is designed to support.
  • Sales competitive intelligence
  • Pricing strategy research
  • Feature gap analysis
  • Product roadmap inputs from competitor sites
  • Battle cards for account executives

Setup

Requirements, wiring steps, and what this pattern adds to your project.

Getting started

Pick how you want to pull this pattern in. Then wire env vars and routes the same way.

  1. 1

    Install from the preview toolbar

    Shadcn Icon

    Copy the install command above and run it in your project — Pro patterns include a short-lived token.

  2. 2

    Add environment variables to .env.local

    OPENAI_API_KEY, FIRECRAWL_API_KEY

  3. 3

    Point client fetches at your API routes

    Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.

  4. 4

    Customize the agent and tool files

    Adapt prompts, tools, and stop conditions for your product — Copy for AI in the toolbar helps seed that work.

  5. 5

    Run your dev server and open the pattern route

    Install dependencies if needed, then start the app and verify responses.

Environment variables

Capabilities

AI SDK APIs

useChatgatewayToolLoopAgenttoolhasToolCallstepCountIscreateAgentUIStreamResponseInferAgentUIMessageDefaultChatTransportUIMessage

Providers

OpenAI

External services

FirecrawlUpstash

Files added

16 files
  • app/page.tsx
  • app/layout.tsx
  • app/api/competitor-agent/route.ts
  • lib/actions.ts
  • lib/competitor-types.ts
  • lib/rate-limit.ts
  • lib/agent-research.ts
  • lib/transform-utils.ts
  • lib/ai/competitor-agent.ts
  • lib/ai/tools/analyze-positioning.ts
  • lib/ai/tools/extract-pricing.ts
  • lib/ai/tools/identify-features.ts
  • lib/ai/tools/analyze-tech-stack.ts
  • lib/ai/tools/find-weaknesses.ts
  • lib/ai/tools/generate-battlecard.ts
  • README.md

Dependencies

14 total

npm packages

8
AISDK@mendable/firecrawl-jsUpstashlucide-reactNext.jsReactsonnerZod

Shadcn IconRegistry components

6
badgebuttoncardinputskeletontabs

Critical files

  • competitor-agent/route.ts

    API route using createAgentUIStreamResponse with competitorContext via callOptions.

  • ai/competitor-agent.ts

    ToolLoopAgent with 6 competitor analysis tools, callOptionsSchema + prepareCall for context injection.

  • lib/actions.ts

    Server action implementing Firecrawl-based competitor scraping pipeline: map website, identify key pages, parallel scrape, LLM extraction via generateObject.

  • lib/agent-research.ts

    Deep research functions (researchPricing, researchFeatures, researchTechStack, researchReviews) with detailed Zod schemas for structured extraction.

  • tools/analyze-positioning.ts

    Tool for extracting value propositions, target audience, and competitive positioning.

  • tools/extract-pricing.ts

    Tool for structuring pricing tiers, models, and billing options from competitor data.

  • tools/identify-features.ts

    Tool for building categorized feature matrices from competitor websites.

  • tools/analyze-tech-stack.ts

    Tool for detecting frontend/backend technologies, infrastructure, and third-party services.

  • tools/find-weaknesses.ts

    Tool for identifying feature gaps, UX issues, and competitive opportunities.

  • tools/generate-battlecard.ts

    Tool for generating comprehensive sales battle cards with objection handling.

Requirements

Complexity
Advanced
Setup time
~10 minutes
Node
24+
Memory
256MB
Upstash Redis