8
n8n 中文网amn8n.com

Recap AI - Facebook广告克隆系统

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 If, Set, Merge, Aggregate, FormTrigger 等节点。 使用Gemini AI和Apify克隆和定制竞争对手的Facebook广告

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "qvBUGGr9hb1LlVuX",
  "meta": {
    "instanceId": "06e5009344f682419c20ccd4ecdcb5223bbb91761882af93ac6d468dbc2cbf8d",
    "templateCredsSetupCompleted": true
  },
  "name": "The Recap AI - Facebook 广告克隆系统",
  "tags": [],
  "nodes": [
    {
      "id": "02aa1570-98cc-4e51-8984-7078b67f8e69",
      "name": "表单触发器",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        224,
        224
      ],
      "webhookId": "739f6e4b-c69f-4baf-b6fe-f671f8ba6279",
      "parameters": {
        "options": {},
        "formTitle": "Facebook Ad Thief Form",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Facebook Ad Library Url",
              "placeholder": "https://www.facebook.com/",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Your Product Image",
              "multipleFiles": false,
              "requiredField": true
            }
          ]
        },
        "formDescription": "Upload your product image and submit a facebook ad library url for the ads you want to clone/spin for your produc.t"
      },
      "typeVersion": 2.2
    },
    {
      "id": "3b44e844-211b-435e-b559-b86f50c969bc",
      "name": "iterate_ads",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        224,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a647a369-8233-4bf1-9fb4-12d40376672c",
      "name": "download_image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        864,
        464
      ],
      "parameters": {
        "url": "={{ $node['iterate_ads'].json.snapshot.cards.first().original_image_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "01df58ea-a0b6-4282-ae66-681bc2dd3ace",
      "name": "convert_ad_image_to_base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1152,
        464
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "508fdd2d-1d9e-437b-83ea-a234eb755195",
      "name": "upload_ad_reference",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1152,
        288
      ],
      "parameters": {
        "name": "={{ $node['iterate_ads'].json.snapshot.cards.first().title }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "1HoXBHX3gvz5TxhczPwI0d5gWI3mxJT7h"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "PgwI1k1VFnoEhOi6",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "6145dd1e-1b1e-4acf-b41c-acdcbcc938d6",
      "name": "merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1424,
        448
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "a01db21f-c4b1-481b-a55b-31ede9b7814d",
      "name": "aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        224,
        704
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3b1c6a2e-eca8-494d-837a-3d09cc482c3d",
      "name": "get_image",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1424,
        720
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "image_result"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2805dfd1-dce7-4d5d-86c9-dc3b925e9249",
      "name": "upload_image",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1712,
        784
      ],
      "parameters": {
        "name": "=Cloned Ad #{{ $runIndex + 1 }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "url",
          "value": "https://drive.google.com/drive/u/0/folders/1qY588PqswUfGTl3dZ_FbZhiDwK0Kv2Mz"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "PgwI1k1VFnoEhOi6",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "2e6a04de-1329-41bb-967a-73aade05fef8",
      "name": "set_result",
      "type": "n8n-nodes-base.set",
      "position": [
        1152,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "524da01b-f8b9-4c2c-9e28-319455903e4d",
              "name": "=image_result",
              "type": "string",
              "value": "={{ $json.candidates[0].content.parts.filter(item => item.inlineData).first().inlineData.data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "23c1e641-04d7-4540-8336-77b24c29007d",
      "name": "check_if_prohibited",
      "type": "n8n-nodes-base.if",
      "position": [
        864,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f46e65cf-d695-4e2e-a64c-be500cd788dd",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.candidates.first().finishReason }}",
              "rightValue": "PROHIBITED_CONTENT"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d09e9817-e30f-4239-b105-e394e0b60d40",
      "name": "convert_product_image_to_base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        528,
        224
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "binaryPropertyName": "Your_Product_Image"
      },
      "typeVersion": 1
    },
    {
      "id": "f9af4c0e-e2d9-479a-a360-703407c0eba3",
      "name": "generate_ad_image_prompt",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        528,
        704
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\": [\n      { \"text\": {{ JSON.stringify($json.prompt) }} },\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/png\",\n          \"data\": \"{{ $node['convert_product_image_to_base64'].json.data }}\"\n        }\n      },\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/jpeg\",\n          \"data\": \"{{ $node['convert_ad_image_to_base64'].json.data }}\"\n        }\n      }\n    ]\n  }]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "abcMckGk9RG9i0Ba",
          "name": "Google Gemini"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "43ae4270-b8d8-4d1d-9e30-024f5b0c1a17",
      "name": "generate_ad_image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        704,
        704
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\": [\n      { \"text\": {{ JSON.stringify($json.candidates.first().content.parts.first().text) }} },\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/png\",\n          \"data\": \"{{ $node['convert_product_image_to_base64'].json.data }}\"\n        }\n      },\n      {\n        \"inline_data\": {\n          \"mime_type\": \"image/jpeg\",\n          \"data\": \"{{ $node['convert_ad_image_to_base64'].json.data }}\"\n        }\n      }\n    ]\n  }]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "abcMckGk9RG9i0Ba",
          "name": "Google Gemini"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "47fa9f9a-6699-4944-9ad0-531ad34b4ead",
      "name": "build_prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        368,
        704
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2fcf84d7-4a17-4899-9bea-a7d3b6027acd",
              "name": "prompt",
              "type": "string",
              "value": "You are an expert in image I need your help to write a perfect prompt that is going to help me generate/edit an image for my company's product called Thrive Mix. Attached to this request are two images: 1. Product picture of Thrive Mix (our product) 2. Reference image of the competitor's ad we're trying to replicate In your analysis of these images, I want you to come up with a plan and write a very detailed prompt on how we can clone and spin the ad from image number two (our competitor AG1) to make an identical ad that features our product with our packaging (ThriveMix) and image number one. We need to replicate the same style used on the AG1 competitor ad, but it should always be our packaging that's included. Some tricky edge cases you need to handle are: Partial branding items of the AG1 text (there can be text that says AG1, labels on products that say AG1, multiple products, multiple packages that are different from ours). Please check for all placements in the AG1 ad that need to be replaced. You need to figure out how to write a specific prompt that is going to detail this image generator how to replace it and create the ad for our product. The end result we're going for is a new ad that promotes our product ThriveMix. Make sure your prompt includes changes that need to be changed on the text of the image like labels and calls to action. It's possible that the source ad image for our competitor AG1 will have partial text on the product or packaging like \"A\", \"AG\", \"G, \"G\" (standalone), \"G1\", or some other partial text that needs to be checked for and analyzed in your plan. Keep the ad copy the same EXCEPT for switching \"AG1\" to \"ThriveMix\" to Think deeply about the prompt you are going to write."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1086bf1c-2495-45a2-93cf-2cefd2e51735",
      "name": "scrape_ads",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        864,
        224
      ],
      "parameters": {
        "memory": 512,
        "actorId": {
          "__rl": true,
          "mode": "list",
          "value": "XtaWFhbtfxyzqrFmd",
          "cachedResultUrl": "https://console.apify.com/actors/XtaWFhbtfxyzqrFmd/input",
          "cachedResultName": "Facebook Ad Library Scraper (curious_coder/facebook-ads-library-scraper)"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"limitPerSource\": 20,\n    \"scrapeAdDetails\": false,\n    \"scrapePageAds.activeStatus\": \"all\",\n    \"scrapePageAds.countryCode\": \"ALL\",\n    \"urls\": [\n        {\n            \"url\": \"{{ $('form_trigger').item.json['Facebook Ad Library Url'] }}\",\n            \"method\": \"GET\"\n        }\n    ]\n}",
        "actorSource": "store",
        "authentication": "apifyOAuth2Api"
      },
      "credentials": {
        "apifyOAuth2Api": {
          "id": "H654WxAlFsyNy0MJ",
          "name": "Apify"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1041b268-c792-4c66-b4b4-18bc477fe4d5",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        96
      ],
      "parameters": {
        "color": 4,
        "width": 1792,
        "height": 960,
        "content": "## Nano Banana Facebook 广告克隆系统"
      },
      "typeVersion": 1
    },
    {
      "id": "24fb842b-4b2d-4c4b-85e3-67a9c2932e6a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        96
      ],
      "parameters": {
        "width": 608,
        "height": 960,
        "content": "## 设置与概述"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5e3b14f9-6688-444c-b973-43aaf9342aae",
  "connections": {
    "merge": {
      "main": [
        [
          {
            "node": "aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "aggregate": {
      "main": [
        [
          {
            "node": "build_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_image": {
      "main": [
        [
          {
            "node": "upload_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "scrape_ads": {
      "main": [
        [
          {
            "node": "iterate_ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set_result": {
      "main": [
        [
          {
            "node": "get_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "iterate_ads": {
      "main": [
        [],
        [
          {
            "node": "download_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "build_prompt": {
      "main": [
        [
          {
            "node": "generate_ad_image_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "form_trigger": {
      "main": [
        [
          {
            "node": "convert_product_image_to_base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upload_image": {
      "main": [
        [
          {
            "node": "iterate_ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download_image": {
      "main": [
        [
          {
            "node": "upload_ad_reference",
            "type": "main",
            "index": 0
          },
          {
            "node": "convert_ad_image_to_base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generate_ad_image": {
      "main": [
        [
          {
            "node": "check_if_prohibited",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check_if_prohibited": {
      "main": [
        [
          {
            "node": "iterate_ads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "set_result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upload_ad_reference": {
      "main": [
        [
          {
            "node": "merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generate_ad_image_prompt": {
      "main": [
        [
          {
            "node": "generate_ad_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "convert_ad_image_to_base64": {
      "main": [
        [
          {
            "node": "merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "convert_product_image_to_base64": {
      "main": [
        [
          {
            "node": "scrape_ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量18
分类2
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Lucas Walter

Lucas Walter

@lucaswalter

Chief Automation Officer at The Recap AI. I build the AI systems and agents that power our business and teach others how to use n8n. Check out our YouTube channel linked below!

外部链接
在 n8n.io 查看

分享此工作流