This automation functions as a comprehensive competitor intelligence tool for Facebook Ads. By scraping the Facebook Ad Library, the workflow captures competitor text, image, and video ads, and processes them through advanced AI models. The system delivers a deep strategic analysis alongside newly generated, rewritten ad variations. Targeted toward PPC agencies and marketers, this tool combines web scraping with multi-modal AI to create a high-value, premium service designed to be sold at the $2,000+ tier.
{
"name": "Facebook Ad Spy & Creative Intelligence",
"nodes": [
{
"parameters": {},
"id": "371d984c-bba0-4b63-8fdf-4c5a22c2a38a",
"name": "When clicking ‘Execute workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1008,
688
],
"typeVersion": 1
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9dbbe6e7-fd80-44ab-88f0-ab438cfd997e",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.snapshot.videos[0].video_sd_url }}",
"rightValue": "=https://video-"
}
]
},
"renameOutput": true,
"outputKey": "Video"
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "0b7cee75-ca57-4946-971e-1f526b49324f",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.snapshot.images[0].original_image_url }}",
"rightValue": "https://scontent-ho"
}
]
},
"renameOutput": true,
"outputKey": "Image"
}
]
},
"options": {
"fallbackOutput": "extra",
"renameFallbackOutput": "Text"
}
},
"id": "0fae97f0-0b8f-4389-95bb-c2fccbe24f76",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
-448,
672
],
"typeVersion": 3.2
},
{
"parameters": {
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c1d74591-13e8-4c79-9a34-117cc6816dfb",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ $json.advertiser.ad_library_page_info.page_info.likes }}",
"rightValue": 1000
}
]
},
"options": {}
},
"id": "e48bee9c-e10a-4734-ac48-f96452846243",
"name": "Filter For Likes",
"type": "n8n-nodes-base.filter",
"position": [
-624,
688
],
"typeVersion": 2.2
},
{
"parameters": {
"amount": 1
},
"id": "d79b43db-2d4e-47ae-9973-b3d996ea9517",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
880,
1120
],
"webhookId": "1cda7407-6321-4d8d-b532-19f42514eb63",
"typeVersion": 1.1
},
{
"parameters": {
"amount": 1
},
"id": "ca3f9f19-b626-4239-a836-26a7173e900b",
"name": "Wait1",
"type": "n8n-nodes-base.wait",
"position": [
880,
864
],
"webhookId": "1cda7407-6321-4d8d-b532-19f42514eb63",
"typeVersion": 1.1
},
{
"parameters": {
"url": "={{ $json.snapshot.videos[0].video_sd_url }}",
"options": {}
},
"id": "92df784f-4234-4856-afa7-7b7125819918",
"name": "Download Video",
"type": "n8n-nodes-base.httpRequest",
"position": [
0,
464
],
"typeVersion": 4.2
},
{
"parameters": {
"name": "Example File",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root",
"cachedResultName": "/ (Root folder)"
},
"options": {}
},
"id": "1e0a4ff5-a310-4983-b16d-bdca211586c3",
"name": "Upload Video to Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
176,
464
],
"typeVersion": 3
},
{
"parameters": {
"amount": 1
},
"id": "58d4fdba-4fce-4919-acf5-f687a4885608",
"name": "Wait2",
"type": "n8n-nodes-base.wait",
"position": [
880,
656
],
"webhookId": "1cda7407-6321-4d8d-b532-19f42514eb63",
"typeVersion": 1.1
},
{
"parameters": {
"method": "POST",
"url": "https://api.apify.com/v2/acts/XtaWFhbtfxyzqrFmd/run-sync-get-dataset-items",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer "
},
{
"name": "Accept",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"count\": 200,\n \"period\": \"last7d\",\n \"scrapeAdDetails\": true,\n \"scrapePageAds.activeStatus\": \"active\",\n \"urls\": [\n {\n \"url\": \"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=%22ai%20automation%22&search_type=keyword_exact_phrase&start_date[min]=2025-06-12&start_date[max]\",\n \"method\": \"GET\"\n }\n ]\n}",
"options": {}
},
"id": "61788f03-3691-4c1a-97a3-a529e974a9ea",
"name": "Run Ad Library Scraper",
"type": "n8n-nodes-base.httpRequest",
"position": [
-816,
688
],
"typeVersion": 4.2
},
{
"parameters": {
"options": {}
},
"id": "128370f6-73d7-4b29-8289-ecba16ff0f84",
"name": "Loop Over Image Ads",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-208,
848
],
"typeVersion": 3
},
{
"parameters": {
"options": {}
},
"id": "168cde0c-9e7d-4d69-af07-0f68b5eda1a0",
"name": "Loop Over Text Ads",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-224,
1072
],
"typeVersion": 3
},
{
"parameters": {
"options": {}
},
"id": "031b493f-fb94-422d-84bd-bad7db79281a",
"name": "Loop Over Video Ads",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-224,
448
],
"typeVersion": 3
},
{
"parameters": {
"method": "POST",
"url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "key",
"value": ""
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "X-Goog-Upload-Protocol",
"value": "resumable"
},
{
"name": "X-Goog-Upload-Command",
"value": "start"
},
{
"name": "X-Goog-Upload-Header-Content-Length",
"value": "={{ $json.size }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"options": {
"response": {
"response": {
"fullResponse": true
}
}
}
},
"id": "b2833052-db8e-4040-8866-08c5c277d25b",
"name": "Begin Gemini Upload Session",
"type": "n8n-nodes-base.httpRequest",
"position": [
336,
464
],
"typeVersion": 4.2
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $('Upload Video to Drive').item.json.id }}"
},
"options": {}
},
"id": "343b3130-748a-4188-9043-c0aaa29faf89",
"name": "Redownload Video",
"type": "n8n-nodes-base.googleDrive",
"position": [
496,
464
],
"typeVersion": 3
},
{
"parameters": {
"method": "POST",
"url": "={{ $json.headers['x-goog-upload-url'] }}",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "key",
"value": ""
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Length",
"value": "={{ $('Upload Video to Drive').item.json.size }}"
},
{
"name": "X-Goog-Upload-Offset",
"value": "0"
},
{
"name": "X-Goog-Upload-Command",
"value": "upload, finalize"
}
]
},
"sendBody": true,
"contentType": "binaryData",
"inputDataFieldName": "=data",
"options": {}
},
"id": "7e87df23-8e66-4184-84e0-e2addb13d37e",
"name": "Upload Video to Gemini",
"type": "n8n-nodes-base.httpRequest",
"position": [
672,
464
],
"typeVersion": 4.2
},
{
"parameters": {
"method": "POST",
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "key",
"value": ""
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"Describe this video in excruciating detail. Do not output anything but the description of the video.\"\n },\n {\n \"file_data\": {\n \"mime_type\": \"{{ $json.file.mimeType }}\",\n \"file_uri\": \"{{ $json.file.uri }}\"\n }\n }\n ]\n }\n ]\n}",
"options": {}
},
"id": "4f79dcee-c4a2-4fd3-ace5-67c06bade894",
"name": "Analyze Video with Gemini",
"type": "n8n-nodes-base.httpRequest",
"position": [
1008,
464
],
"retryOnFail": true,
"typeVersion": 4.2,
"waitBetweenTries": 15
},
{
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1",
"cachedResultName": "GPT-4.1"
},
"messages": {
"values": [
{
"content": "You're a helpful, intelligent advertisement analysis bot. You analyze advertisements.",
"role": "system"
},
{
"content": "Your task is to take as input a scraped javascript object from an advertisement in the FB ad library, and then summarize it + spin (repurpose, rewrite) the ad copy. \n\nYou're doing this for strategic intelligence. We run an advertising agency and we're always looking at what our competitor advertisers are doing.\n\nOutput your results in this JSON format:\n\n{\"summary\":\"\",\"rewrittenAdCopy\":\"\"}\n\nRules:\n- The intended style and attitude is generally analytical, inquisitive, and precise, despite exploring complex topics, in the “classic style” of Western writing.\nthe level of formality should be inverse to the topic’s novelty: the weirder something is, the more formal. For ‘safer’ topics, one should cut loose with the humor, epigraphs, typographical stunts and experiments, etc.\n- Avoid hedging and qualifying, even at the risk of making overly-strong claims. It is a slippery slope.\n- Use casual abbreviations (like San Francisco -> SF, thanks -> thx, question -> q ), casual contractions (like \"I've\"), shortened forms of common nouns (like \"info\", \"vid\", \"app\") as this signals more human written speech. Do not use em dashes (eliminate — from your vocabulary completely!\n- No rhetorical questions.\n- Make your summary extremely comprehensive and analytical."
},
{
"content": "=JSON scrape:\n\n{{ $('Loop Over Video Ads').item.json.toJsonString() }}\n\nVideo description:\n\n{{ $json.candidates[0].content.parts[0].text }}"
}
]
},
"jsonOutput": true,
"options": {
"temperature": 0.7
}
},
"id": "de0fa809-17a0-468e-a571-ae26aece281b",
"name": "Output Video Summary",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-160,
656
],
"typeVersion": 1.8
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit?usp=drivesdk",
"cachedResultName": "Facebook Ad Library Analyzer DB"
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit#gid=0",
"cachedResultName": "Ads"
},
"columns": {
"value": {
"type": "video",
"page_id": "={{ $('Loop Over Video Ads').item.json.page_id }}",
"summary": "={{ $json.message.content.summary }}",
"page_url": "={{ $('Loop Over Video Ads').item.json.snapshot.page_profile_uri }}",
"page_name": "={{ $('Loop Over Video Ads').item.json.snapshot.page_name }}",
"date_added": "={{ $now }}",
"image_prompt": "=",
"video_prompt": "={{ $('Analyze Video with Gemini').item.json.candidates[0].content.parts[0].text }}",
"ad_archive_id": "={{ $('Loop Over Video Ads').item.json.ad_archive_id }}",
"rewritten_ad_copy": "={{ $json.message.content.rewrittenAdCopy }}"
},
"schema": [
{
"id": "ad_archive_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_archive_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date_added",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "date_added",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "summary",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "rewritten_ad_copy",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "rewritten_ad_copy",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "image_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "image_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "video_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "video_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"id": "d3becf3e-d0db-4193-a694-58187ad3f9b2",
"name": "Add as Type = Video",
"type": "n8n-nodes-base.googleSheets",
"position": [
272,
656
],
"typeVersion": 4.6
},
{
"parameters": {
"resource": "image",
"operation": "analyze",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"text": "What's in this image? Be extremely comprehensive.",
"imageUrls": "={{ $json.snapshot.images[0].original_image_url }}",
"options": {}
},
"id": "e1b6d609-753a-41be-9949-576f2235680c",
"name": "Analyze Image",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
80,
864
],
"typeVersion": 1.8
},
{
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1",
"cachedResultName": "GPT-4.1"
},
"messages": {
"values": [
{
"content": "You're a helpful, intelligent advertisement analysis bot. You analyze advertisements.",
"role": "system"
},
{
"content": "Your task is to take as input a scraped javascript object from an advertisement in the FB ad library, and then summarize it + spin (repurpose, rewrite) the ad copy. \n\nYou're doing this for strategic intelligence. We run an advertising agency and we're always looking at what our competitor advertisers are doing.\n\nOutput your results in this JSON format:\n\n{\"summary\":\"\",\"rewrittenAdCopy\":\"\"}\n\nRules:\n- The intended style and attitude is generally analytical, inquisitive, and precise, despite exploring complex topics, in the “classic style” of Western writing.\nthe level of formality should be inverse to the topic’s novelty: the weirder something is, the more formal. For ‘safer’ topics, one should cut loose with the humor, epigraphs, typographical stunts and experiments, etc.\n- Avoid hedging and qualifying, even at the risk of making overly-strong claims. It is a slippery slope.\n- Use casual abbreviations (like San Francisco -> SF, thanks -> thx, question -> q ), casual contractions (like \"I've\"), shortened forms of common nouns (like \"info\", \"vid\", \"app\") as this signals more human written speech. Do not use em dashes (eliminate — from your vocabulary completely!\n- No rhetorical questions.\n- Make your summary extremely comprehensive and analytical."
},
{
"content": "=JSON scrape:\n\n{{ $('Loop Over Image Ads').item.json.toJsonString() }}\n\nImage description:\n\n{{ $json.content }}"
}
]
},
"jsonOutput": true,
"options": {
"temperature": 0.7
}
},
"id": "e23780ce-9cc2-46c2-97d9-2d2d0dc17cb8",
"name": "Output Image Summary",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
288,
864
],
"typeVersion": 1.8
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit?usp=drivesdk",
"cachedResultName": "Facebook Ad Library Analyzer DB"
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit#gid=0",
"cachedResultName": "Ads"
},
"columns": {
"value": {
"type": "image",
"page_id": "={{ $('Loop Over Image Ads').item.json.page_id }}",
"summary": "={{ $json.message.content.summary }}",
"page_url": "={{ $('Loop Over Image Ads').item.json.snapshot.page_profile_uri }}",
"page_name": "={{ $('Loop Over Image Ads').item.json.snapshot.page_name }}",
"date_added": "={{ $now }}",
"image_prompt": "={{ $('Analyze Image').item.json.content }}",
"ad_archive_id": "={{ $('Loop Over Image Ads').item.json.ad_archive_id }}",
"rewritten_ad_copy": "={{ $json.message.content.rewrittenAdCopy }}"
},
"schema": [
{
"id": "ad_archive_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_archive_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date_added",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "date_added",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "summary",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "rewritten_ad_copy",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "rewritten_ad_copy",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "image_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "image_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "video_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "video_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"id": "a4fbe6a1-0c2f-463e-bdf9-6fcb167473e2",
"name": "Add as Type = Image",
"type": "n8n-nodes-base.googleSheets",
"position": [
640,
864
],
"typeVersion": 4.6
},
{
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1",
"cachedResultName": "GPT-4.1"
},
"messages": {
"values": [
{
"content": "You're a helpful, intelligent advertisement analysis bot. You analyze advertisements.",
"role": "system"
},
{
"content": "Your task is to take as input a scraped javascript object from an advertisement in the FB ad library, and then summarize it + spin (repurpose, rewrite) the ad copy. \n\nYou're doing this for strategic intelligence. We run an advertising agency and we're always looking at what our competitor advertisers are doing.\n\nOutput your results in this JSON format:\n\n{\"summary\":\"\",\"rewrittenAdCopy\":\"\"}\n\nRules:\n- The intended style and attitude is generally analytical, inquisitive, and precise, despite exploring complex topics, in the “classic style” of Western writing.\nthe level of formality should be inverse to the topic’s novelty: the weirder something is, the more formal. For ‘safer’ topics, one should cut loose with the humor, epigraphs, typographical stunts and experiments, etc.\n- Avoid hedging and qualifying, even at the risk of making overly-strong claims. It is a slippery slope.\n- Use casual abbreviations (like San Francisco -> SF, thanks -> thx, question -> q ), casual contractions (like \"I've\"), shortened forms of common nouns (like \"info\", \"vid\", \"app\") as this signals more human written speech. Do not use em dashes (eliminate — from your vocabulary completely!\n- No rhetorical questions.\n- Make your summary extremely comprehensive and analytical."
},
{
"content": "={{ $json.toJsonString() }}"
}
]
},
"jsonOutput": true,
"options": {
"temperature": 0.7
}
},
"id": "76110cea-9c64-477e-a39e-26c2d6829e43",
"name": "Output Text Summary",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
16,
1120
],
"typeVersion": 1.8
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"mode": "list",
"value": "1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit?usp=drivesdk",
"cachedResultName": "Facebook Ad Library Analyzer DB"
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Cgm0DfKQxgtsjdw6h2LFVBtZnLAioTntzdXgfJCJIqo/edit#gid=0",
"cachedResultName": "Ads"
},
"columns": {
"value": {
"type": "text",
"page_id": "={{ $('Loop Over Text Ads').item.json.page_id }}",
"summary": "={{ $json.message.content.summary }}",
"page_url": "={{ $('Loop Over Text Ads').item.json.snapshot.page_profile_uri }}",
"page_name": "={{ $('Loop Over Text Ads').item.json.snapshot.page_name }}",
"date_added": "={{ $now }}",
"ad_archive_id": "={{ $('Loop Over Text Ads').item.json.ad_archive_id }}",
"rewritten_ad_copy": "={{ $json.message.content.rewrittenAdCopy }}"
},
"schema": [
{
"id": "ad_archive_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ad_archive_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "type",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date_added",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "date_added",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page_url",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page_url",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "summary",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "rewritten_ad_copy",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "rewritten_ad_copy",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "image_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "image_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "video_prompt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "video_prompt",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"id": "b9f76531-9dd0-44eb-8e29-07038a1ec9a0",
"name": "Add as Type = Text",
"type": "n8n-nodes-base.googleSheets",
"position": [
368,
1120
],
"typeVersion": 4.6
},
{
"parameters": {
"amount": 15
},
"id": "9422e4ed-19f9-4943-a6b4-b8693375e401",
"name": "Wait3",
"type": "n8n-nodes-base.wait",
"position": [
848,
464
],
"webhookId": "ac11c85a-5b73-4a29-9667-615e811a5ad8",
"typeVersion": 1.1
}
],
"pinData": {},
"connections": {
"Wait": {
"main": [
[
{
"node": "Loop Over Text Ads",
"type": "main",
"index": 0
}
]
]
},
"Wait1": {
"main": [
[
{
"node": "Loop Over Image Ads",
"type": "main",
"index": 0
}
]
]
},
"Wait2": {
"main": [
[
{
"node": "Loop Over Video Ads",
"type": "main",
"index": 0
}
]
]
},
"Wait3": {
"main": [
[
{
"node": "Analyze Video with Gemini",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Loop Over Video Ads",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Image Ads",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Text Ads",
"type": "main",
"index": 0
}
]
]
},
"Analyze Image": {
"main": [
[
{
"node": "Output Image Summary",
"type": "main",
"index": 0
}
]
]
},
"Download Video": {
"main": [
[
{
"node": "Upload Video to Drive",
"type": "main",
"index": 0
}
]
]
},
"Filter For Likes": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Redownload Video": {
"main": [
[
{
"node": "Upload Video to Gemini",
"type": "main",
"index": 0
}
]
]
},
"Add as Type = Text": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Text Ads": {
"main": [
[],
[
{
"node": "Output Text Summary",
"type": "main",
"index": 0
}
]
]
},
"Add as Type = Image": {
"main": [
[
{
"node": "Wait1",
"type": "main",
"index": 0
}
]
]
},
"Add as Type = Video": {
"main": [
[
{
"node": "Wait2",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Image Ads": {
"main": [
[],
[
{
"node": "Analyze Image",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Video Ads": {
"main": [
[],
[
{
"node": "Download Video",
"type": "main",
"index": 0
}
]
]
},
"Output Text Summary": {
"main": [
[
{
"node": "Add as Type = Text",
"type": "main",
"index": 0
}
]
]
},
"Output Image Summary": {
"main": [
[
{
"node": "Add as Type = Image",
"type": "main",
"index": 0
}
]
]
},
"Output Video Summary": {
"main": [
[
{
"node": "Add as Type = Video",
"type": "main",
"index": 0
}
]
]
},
"Upload Video to Drive": {
"main": [
[
{
"node": "Begin Gemini Upload Session",
"type": "main",
"index": 0
}
]
]
},
"Run Ad Library Scraper": {
"main": [
[
{
"node": "Filter For Likes",
"type": "main",
"index": 0
}
]
]
},
"Upload Video to Gemini": {
"main": [
[
{
"node": "Wait3",
"type": "main",
"index": 0
}
]
]
},
"Analyze Video with Gemini": {
"main": [
[
{
"node": "Output Video Summary",
"type": "main",
"index": 0
}
]
]
},
"Begin Gemini Upload Session": {
"main": [
[
{
"node": "Redownload Video",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Run Ad Library Scraper",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "3a6f3cc8-119d-464d-a746-81cd7cb76655",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "c67be5f581054330a3fd31a240fe0e3398a9d5d32899fb041e2ae647624d8663"
},
"id": "uLiIomCUdsSehar2",
"tags": []
}
Here is a structured, highly scannable rewrite of your workflow documentation, designed to be professional, engaging, and easy to read.

The Complete Facebook Ad Spy Tool Workflow
This multi-modal automation acts as an advanced competitive intelligence engine. By scraping the Facebook Ad Library and processing creatives through specialized AI models, it delivers deep strategic insights and ready-to-use ad copy.
Overview & Requirements
| Metric | Details |
| Difficulty Level | Advanced |
| Estimated Build Time | 3 to 4 hours |
| Monthly Operating Cost | ~$200 (Apify, OpenAI, Gemini, and Google Workspace APIs) |
| Premium Potential | Can be sold to agencies and marketers for $2,000+ |
Core Benefits
- Complete Competitive Intelligence: Analyze competitor strategies across all formats, including text, images, and video.
- Multi-Modal AI Analysis: Leverages GPT-4 Vision for deep image understanding and Gemini for advanced video content analysis.
- Automated Ad Rewriting: Instantly generates highly optimized, inspired variations of successful competitor campaigns.
- Strict Quality Filtering: Automatically filters for high-performing advertisers with significant page likes to ensure quality data.
- Massive Scalability: Process hundreds of competitor ads simultaneously without breaking rate limits.
How the Engine Works
1. Facebook Ad Library Scraping
The workflow connects to Facebook’s public ad library via a specialized Apify scraper. It searches for active campaigns using custom keywords, extracts the creative assets and targeting data, and filters the results to isolate high-quality advertisers.
2. Intelligent Content Routing
Extracted ads are automatically categorized into text-only, image-based, or video formats. The system then routes each asset to its corresponding AI processing pipeline to ensure the correct model handles the analysis.
3. Advanced Video Analysis Pipeline
Video ads are downloaded directly from Facebook’s CDN and temporarily stored in Google Drive. A Gemini AI session is initiated to analyze the video’s narrative, visual elements, messaging strategy, and target audience.
4. Image and Text Processing
GPT-4 Vision takes over the image ads, breaking down the visual components. Standard GPT-4 analyzes text-only ads to identify persuasion techniques, target demographics, and copywriting frameworks.
5. Strategic Intelligence Generation
The final output includes comprehensive competitor summaries, rewritten ad copy that captures the winning elements (without plagiarizing), and image/video prompts that can be fed into AI generation tools. Everything is logged into a structured database.
Google Sheets Database Structure
To organize the intelligence, your Google Sheet should be configured with the following columns:
| Column Name | Data Stored |
ad_archive_id | Unique Facebook ad identifier |
page_id | Advertiser’s Facebook page ID |
page_name | Advertiser’s business name |
page_url | Link to the advertiser’s Facebook page |
type | Ad format (text, image, or video) |
date_added | Date the ad was scraped and analyzed |
summary | Detailed competitive intelligence analysis |
rewritten_ad_copy | AI-generated inspired version of the ad |
image_prompt | AI description for recreating the image creative |
video_prompt | AI description for recreating the video creative |
Setup & Configuration Guide
Apify Integration
- Create an Apify account and generate an API key.
- Insert the key into the
Run Ad Library Scrapernode, replacing<your-apify-api-key-here>. - Customize the target keywords, regions, and quality filters (e.g., setting a 1,000+ page likes threshold in the filter node).
AI Service Configuration
- OpenAI: Authenticate your API keys for text and GPT-4 Vision analysis.
- Gemini: Authenticate your API key for video content analysis, replacing
<your-gemini-api-key-here>in all related nodes. - Set up appropriate rate limits and error-handling delays to maintain API stability.
Google Services Integration
- Configure Google Drive OAuth to allow temporary video storage during processing.
- Connect your properly formatted Google Sheets database to store the final intelligence reports.
Business Use Cases
- PPC Agencies: Offer comprehensive competitor analysis as a premium, high-ticket client service.
- Marketing Teams & E-commerce: Research industry-leading messaging and creatives before launching new campaigns.
- SaaS & Course Creators: Study how competitors position their digital products and educational content.
- Affiliate Marketers: Quickly identify high-converting promotional strategies and winning ad formats.
Advanced Features & Considerations
Why This System Works: The true advantage is the strategic depth. By covering every ad format and automating the research at scale, it turns weeks of manual competitor analysis into a seamless, immediate process.
Scaling & Customization: You can easily extend this build to include industry-specific prompt constraints, trend-tracking alerts for when competitors launch new campaigns, and automated client-ready report generation.
Important Legal Note: The AI is strictly prompted to generate inspired variations rather than direct copies, ensuring content rights and legal compliance are maintained.






