TemplatesReal-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

    Download → Next.js app

    Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).

  2. 2

    Extract the zip and install dependencies

    Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.

  3. 3

    Fill .env.local

    The download includes .env.local placeholders when needed. Add real values for: OPENAI_API_KEY, FIRECRAWL_API_KEY.

  4. 4

    Customize the agent and tool files

    Adapt prompts, tools, and stop conditions in the generated project for your product.

  5. 5

    Run the app and open the pattern route

    Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route 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