Track and classify Facebook ad angles with Apify, OpenAI, and Supabase

Go to Workflow
0 views
Built by Apify Apify
Created on September 07, 2026

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 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/.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.

Nodes Used (7)

Code
n8n-nodes-base.code
Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi
Supabase
n8n-nodes-base.supabase
Supabase Vector Store
@n8n/n8n-nodes-langchain.vectorStoreSupabase