Showcase > Research & Data

Facebook Ad to Amazon Product Search

17-node n8n workflow using Apify, OpenAI, and Google Sheets to match Facebook ads to Amazon product listings.

ShowcaseIntermediate5 min read

A 17-node competitive intelligence pipeline that reverse-engineers what products Facebook advertisers are selling on Amazon. This workflow scrapes the Facebook Ad Library via Apify, uses OpenAI to extract product names from ad creative and copy, then searches Amazon (also via Apify) to find the exact listings. It is the kind of research tool that turns hours of manual competitor analysis into a single automated run.

Nodes Category Complexity Key Integrations
17 E-Commerce / Research Intermediate Apify (Facebook + Amazon), OpenAI, Google Sheets

Prerequisites

  • Apify account with access to Facebook Ad Library and Amazon scraper actors
  • OpenAI API key for product name extraction from ad creative
  • Google Sheets OAuth2 credentials for results storage
  • Knowledge level: Intermediate -- requires understanding of Apify actors, batch processing, and basic API configuration

Estimated Setup Time

30-40 minutes including Apify actor setup, OpenAI credential connection, and Google Sheets template preparation.

What It Does

This workflow starts by querying the Facebook Ad Library through Apify's scraping infrastructure. It pulls active ads from specified advertisers or categories, capturing ad creative, copy text, landing page URLs, and engagement metrics. The raw ad data feeds into a dual-path processing pipeline.

The first path handles ads that link directly to Amazon product pages. These URLs are parsed and the ASINs are extracted directly -- no AI needed. The second path handles ads that do not link to Amazon. OpenAI analyzes the ad creative and copy text to extract the most likely product name, which is then used to search Amazon via a second Apify scraper.

Both paths converge at a filtering and deduplication stage that removes irrelevant results, scores matches by confidence, and writes the final product-to-ad mapping to Google Sheets. The result is a clean spreadsheet linking Facebook advertising activity to specific Amazon product listings.

Workflow Diagram

Workflow Diagram

Node Breakdown

Triggers

  • Manual Trigger

Scraping

  • HTTP Request x4 (Apify)

AI & Extraction

  • OpenAI

Logic & Processing

  • Code
  • IF x2
  • Split In Batches
  • Set x3
  • Filter
  • Limit

Storage

  • Google Sheets

Step-by-Step Flow

  1. Manual Trigger -- The workflow starts on demand. Input parameters define the target advertisers, ad categories, or keywords to search in the Facebook Ad Library.

  2. Facebook Ad Scraping -- An HTTP Request node calls Apify's Facebook Ad Library scraper. The scraper returns ad creative URLs, ad copy text, landing page destinations, advertiser names, and activity dates for all matching ads.

  3. URL Analysis -- An IF node examines each ad's landing page URL. Ads linking directly to Amazon URLs (containing amazon.com/dp/ or ASIN patterns) take the direct extraction path. All other ads take the AI extraction path.

  4. Direct Path: ASIN Extraction -- For Amazon-linked ads, a Code node parses the ASIN directly from the URL. No AI is needed -- the product identifier is embedded in the link structure.

  5. AI Path: Product Name Extraction -- For non-Amazon ads, OpenAI analyzes the ad copy and creative description to identify the most likely product name. The AI accounts for branded language, promotional phrasing, and indirect product references to extract a clean, searchable product name.

  6. Amazon Product Search -- The extracted product names are sent to Apify's Amazon scraper in batches. The Split In Batches node manages throughput to respect API rate limits. Each search returns matching Amazon product listings with titles, prices, ratings, and ASINs.

  7. Filtering and Scoring -- A Code node scores each Amazon result against the original ad data. Exact title matches score highest, partial keyword matches score lower, and irrelevant results are filtered out. The Filter and Limit nodes ensure only high-confidence matches pass through.

  8. Results Storage -- The final matched products are written to Google Sheets with full attribution: the original Facebook ad, the advertiser, the matched Amazon listing, the match confidence score, and the product details.

What Sets It Apart

Dual-scraper architecture via Apify. Using Apify for both Facebook Ad Library and Amazon scraping provides consistent, reliable data extraction without building custom scrapers. Apify handles anti-bot measures, rate limiting, and page rendering for both platforms.

AI product name extraction. When ads do not link directly to Amazon, OpenAI extracts the product name from ad creative -- cutting through marketing language, brand names, and promotional copy to identify what is actually being sold. This is the step that makes the workflow usable for the majority of ads that do not include direct Amazon links.

Dual-path logic. The IF-based branching handles both scenarios efficiently: direct Amazon URLs are processed instantly via string parsing, while non-Amazon ads go through the AI extraction pipeline. This minimizes unnecessary AI calls and reduces both latency and cost.

Cost Considerations

  • Apify: Free tier includes $5/month platform credits. Facebook Ad Library scraper and Amazon scraper consume ~$0.25-1.00 per run depending on ad volume. Paid plans from $49/month for heavier usage
  • OpenAI: Only used for non-Amazon-linked ads; ~$0.01-0.05 per ad analyzed
  • Google Sheets: Free with Google account
  • Estimated cost per run: $0.50-2.00 depending on the number of ads scraped and processed

Ideal For

  • E-commerce researchers mapping advertising activity to product listings
  • Dropshippers identifying products with active advertising investment
  • Competitive analysts tracking which products competitors are promoting
  • Amazon sellers discovering new product opportunities through advertising trends

Tip: Key Techniques

Apify for Multi-Platform Scraping -- Apify provides pre-built scrapers for both Facebook and Amazon, eliminating the need to build and maintain custom scraping infrastructure. This significantly reduces development time and ongoing maintenance.

Dual-Path Processing -- When different input types require different processing approaches, use IF nodes to branch early. Direct Amazon URLs are cheap to process (string parsing); non-Amazon ads are expensive (AI extraction). Branch early to minimize unnecessary AI calls.

Batch Processing with Rate Limits -- The Split In Batches node is essential when downstream APIs have rate limits. Process items in controlled batches rather than firing all requests simultaneously, which prevents API throttling and ensures reliable completion.

Download

The workflow.json file in this folder can be imported directly into your n8n instance via Settings > Import Workflow.

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.