Back to Templates

Scrape and analyze Facebook ads with Apify, Gemini, GPT‑4.1 and Veo 3

Last update

Last update 7 hours ago

Share


How it works

1. Scrape ads – Pulls Facebook Ad Library data for "ai automation" keywords using Apify

2. Filter & sort – Filters ads by page likes (>1,000) and separates into videos, images, and text ads

3. Analyze creative – For videos: uploads to Gemini for detailed description. For images: analyzes with GPT-4V. For text: rewrites copy using GPT-4.1

4. Generate new ad – Creates a Veo 3 prompt from the analysis, generates an 8-second video clip, and converts it to 9:16 vertical format

5. Add captions – Overlays rewritten ad copy as captions using Creatomate

6. Log results – Uploads final video to GCS and logs all data (analysis, prompts, URLs) to Google Sheets


Set up steps

  1. API Keys – Set up accounts for Apify, Google Cloud (Gemini + GCS), OpenAI, Shotstack, and Creatomate

  2. Credentials in n8n – Add each API key as a credential in your n8n instance

  3. Configure variables – Update the SET1 node with your Google Cloud PROJECT_ID and CLIENT_EMAIL

  4. Set up Google Sheet – Create a sheet with columns matching the schema (ad_archive_id, page_name, summary, rewritten_ad_copy, etc.)

  5. Test – Execute the workflow to scrape, analyze, and generate a new ad variation