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
ads table and, for successfully inserted rows, embeds the ad copy with OpenAI embeddings into a Supabase documents vector 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 Supabase products table.
Setup
- Create and select an Apify API token credential for the Apify node and ensure the workflow uses the
curious_coder/facebook-ads-library-scraper actor.
- Add an OpenAI API credential for both the ad-angle classification and embeddings steps.
- Add a Supabase credential and create the
ads, products, and documents tables in your Supabase project (with pgvector enabled for the vector store).
- Update the Facebook Ad Library search URL and
maxAds values 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.