๐ Track and classify Facebook ad angles with Apify, OpenAI, and Supabase
โก 8 views ยท ๐ Market Research & Insights
๐ก Pro Tip โ If youโve run into Facebookโs Graph API permission restrictions, ScraperNode is a community node that scrapes pages, groups, posts, and comments directly โ no app review needed.
Description
Quick overview
This workflow manually scrapes Facebook Ad Library results via Apify, normalizes each ad and extracts destinations, classifies the adโs persuasion angle with OpenAI, stores ads and related Shopify product data in Supabase, and embeds ad copy into a Supabase vector store for semantic search.
How it works
- Starts when you manually run the workflow and defines the Facebook Ad Library search URL and maximum number of ads to scrape.
- Runs the Apify Facebook Ad Library Scraper actor to collect ad details (copy, creatives, reach, and dates) from the provided search URL.
- Normalizes each ad into a consistent row, unwraps Facebook redirect links to the real destination, derives the destination domain, and builds a Shopify probe URL.
- Sends each adโs text to OpenAI to label its primary persuasion angle (for example urgency, social proof, or problem solution).
- Inserts the enriched ad record into a Supabase
adstable and, for successfully inserted rows, embeds the ad copy with OpenAI embeddings into a Supabasedocumentsvector store with metadata. - For ads with a valid Shopify probe URL, requests
/products.json(or a specific/products/<handle>.json), deduplicates products by product ID, and inserts them into a Supabaseproductstable.
Setup
- Create and select an Apify API token credential for the Apify node and ensure the workflow uses the
curious_coder/facebook-ads-library-scraperactor. - Add an OpenAI API credential for both the ad-angle classification and embeddings steps.
- Add a Supabase credential and create the
ads,products, anddocumentstables in your Supabase project (withpgvectorenabled for the vector store). - Update the Facebook Ad Library search URL and
maxAdsvalues in the dataset input step to match your keyword/country and desired scrape size.
Requirements
- Apify, OpenAI and Supabase accounts.
Customization
- Swap the Ad Library URL for a different keyword, country, or product category. Edit the classification prompt to use angle labels for your niche, or add a Slack node after Insert ad row to alert the team on a new high-reach ad.
๐ Nodes Used
HTTP Request, Supabase, Filter, Embeddings OpenAI, Supabase Vector Store, Default Data Loader
๐ฅ Import
Download workflow.json and import into n8n:
Workflow menu โ Import from File