Scrape competitor ad creative from Meta Ads Library and Google Ads Transparency, then break down hooks, offers, and visual patterns into a strategy doc.
You are a competitive ad intelligence analyst. You reverse-engineer what is working in a competitor's paid acquisition. WORKFLOW: 1. Call scrape_meta_ads with the competitor's brand name to pull active ads from Meta Ads Library. 2. Call scrape_google_ads to pull from Google Ads Transparency Center. 3. Call analyze_creative on each ad to extract hook, offer, CTA, visual style, target persona. 4. Call build_intel_doc to consolidate into a strategy doc with patterns and gaps to exploit. RULES: - Never copy ad copy verbatim — extract patterns, not creative. - Flag ads running for 30+ days as "winners" and analyze them in detail. - Group ads by funnel stage (awareness, consideration, conversion) before analyzing. - Output the gaps in their strategy as a section the user can act on this week.
import { agent, tool } from "@agent-sdk"
import { z } from "zod"
const scrapeInput = z.object({
brand: z.string(),
region: z.string().default("US"),
})
const analyzeInput = z.object({
ads: z.array(z.any()).min(1),
})
export default agent({
model: "claude-sonnet-4-6",
permissionMode: "bypassPermissions",
maxTurns: 25,
systemPrompt: `...`, // see System Prompt section above
tools: {
scrape_meta_ads: tool({
description: "Pull active ads from Meta Ads Library",
inputSchema: scrapeInput,
execute: async ({ brand, region }) => {
// Browser Use → facebook.com/ads/library
},
}),
scrape_google_ads: tool({
description: "Pull from Google Ads Transparency Center",
inputSchema: scrapeInput,
execute: async ({ brand, region }) => {
// Browser Use → adstransparency.google.com
},
}),
analyze_creative: tool({
description: "Extract hook, offer, CTA, visual style, persona",
inputSchema: analyzeInput,
execute: async ({ ads }) => {
// returns array of structured creative breakdowns
},
}),
build_intel_doc: tool({
description: "Consolidate into actionable strategy doc",
inputSchema: z.object({ analyses: z.array(z.any()) }),
execute: async ({ analyses }) => {
// returns markdown doc with patterns + gaps
},
}),
},
})BROWSERBASE_API_KEYBrowserbase key for headless scrapingAGENT_API_KEYServer-side API key for token exchangeA media buyer charges $150/hr to do this manually and misses half the patterns. Run it weekly across 5 competitors for the cost of one freelance hour.