๐Ÿ“Š 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.

View All Scrapers

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

  1. Starts when you manually run the workflow and defines the Facebook Ad Library search URL and maximum number of ads to scrape.
  2. Runs the Apify Facebook Ad Library Scraper actor to collect ad details (copy, creatives, reach, and dates) from the provided search URL.
  3. 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.
  4. Sends each adโ€™s text to OpenAI to label its primary persuasion angle (for example urgency, social proof, or problem solution).
  5. 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.
  6. 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

  1. 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.
  2. Add an OpenAI API credential for both the ad-angle classification and embeddings steps.
  3. Add a Supabase credential and create the ads, products, and documents tables in your Supabase project (with pgvector enabled for the vector store).
  4. 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

Customization

๐Ÿ”— 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

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup