AutomationFlowsAI & RAG › Generate Competitor Ad Images from Product Photos

Generate Competitor Ad Images from Product Photos

Original n8n title: Generate Competitor-style Image Ads From Your Product Photos with Gemini

ByPratyush Kumar Jha @pratyush on n8n.io

This n8n workflow automates “cloning” a competitor ad style and re-generating it using your product image. A user uploads your product image and provides a competitor ad URL via a form trigger; the workflow downloads both images, converts them to inline/base64 parts, builds a…

Event trigger★★★★☆ complexity14 nodesForm TriggerHTTP Request
AI & RAG Trigger: Event Nodes: 14 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #13209 — we link there as the canonical source.

This workflow follows the Form Trigger → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "dVdQ40xm6xUuMToE",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Image Ad Cloner AI Agent",
  "tags": [],
  "nodes": [
    {
      "id": "cde8e8f1-fa9a-4d9a-b090-1e58d2f7c8fd",
      "name": "form_trigger",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -800,
        -432
      ],
      "parameters": {
        "options": {},
        "formTitle": "Facebook Ad Thief Form",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Competitor Image Link",
              "placeholder": "https://www.facebook.com/",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Your Product Image",
              "multipleFiles": false,
              "requiredField": true
            },
            {
              "fieldLabel": "Additional changes"
            }
          ]
        },
        "formDescription": "Upload your product image and submit a competitor image url for the ads you want to clone/spin for your product"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e358408a-4da1-4f75-9e49-b72935f38f9d",
      "name": "download_image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -352,
        -432
      ],
      "parameters": {
        "url": "={{ $('form_trigger').item.json['Competitor Image Link'] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "af21823c-f491-442d-844e-36ef435f2709",
      "name": "convert_ad_image_to_base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -128,
        -432
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "9946c255-5b00-4d02-a1b2-0ea702a7186b",
      "name": "get_image",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1216,
        -432
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "image_result"
      },
      "typeVersion": 1.1
    },
    {
      "id": "600e07e0-9e55-48c2-9e37-f63c1775e785",
      "name": "set_result",
      "type": "n8n-nodes-base.set",
      "position": [
        992,
        -432
      ],
      "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": "cbf6d842-4292-4e33-8d6b-f17327f8ae44",
      "name": "convert_product_image_to_base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -576,
        -432
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "binaryPropertyName": "Your_Product_Image"
      },
      "typeVersion": 1
    },
    {
      "id": "d18e9368-edf1-40b2-92fb-109ca6893b40",
      "name": "generate_ad_image_prompt",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        -432
      ],
      "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": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "c99b2abb-e1f9-4133-9d8b-0ce22a8ce310",
      "name": "generate_ad_image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        -432
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image: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": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "63bc2fec-26c3-47cc-86df-026f831b9fda",
      "name": "build_prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        96,
        -432
      ],
      "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. Attached to this request are two images: 1. Product picture  (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) to make an identical ad that features our product with our packaging  and image number one. We need to replicate the same style used on the  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 text (there can be text that says , labels on products that say , multiple products, multiple packages that are different from ours). Please check for all placements in the  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 . 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  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 competitor brand name to our name to Think deeply about the prompt you are going to write. Also consider any additional changes requested   such as {{ $('form_trigger').item.json['Additional changes'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c6a71cd4-b74f-4ef2-a098-c82907594c8c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -528
      ],
      "parameters": {
        "width": 694,
        "height": 688,
        "content": "# Image Ad Cloner AI Agent \n\nThis n8n workflow automates \u201ccloning\u201d a competitor ad style and re-generating it using your product image. A user uploads your product image and provides a competitor ad URL via a form trigger; the workflow downloads both images, converts them to inline/base64 parts, builds a detailed generation prompt, sends the request to a generative-vision model (Gemini-style endpoints), waits for the result, converts the output back to a file and returns it. Use-cases: rapid ad iteration, creative A/B variants, and scaled ad re-skins.\n\n\n## How it works (step-by-step)\n1. `form_trigger` \u2014 user submits: competitor image URL, their product file, and optional changes.  \n2. `convert_product_image_to_base64` \u2014 converts uploaded product file to base64 inline data.  \n3. `download_image` \u2014 fetches the competitor ad image from the provided URL.  \n4. `convert_ad_image_to_base64` \u2014 converts downloaded competitor image to base64 inline data.  \n5. `build_prompt` \u2014 assembles a careful prompt (handles partial text, labels, placements, CTA swaps, additional changes).  \n6. `generate_ad_image_prompt` \u2192 `generate_ad_image` \u2014 two HTTP Request nodes call generative endpoints (first to prepare prompt/content and then flash-image generation). These include inline image data and model-specific parameters.  \n7. `Wait` \u2014 allows async generation to complete (workflow uses a wait/webhook pattern).  \n8. `set_result` \u2192 `get_image` \u2014 extract image result, convert binary to file for downstream use (download or return to the requester).  \n9. `Sticky Note` \u2014 visual diagram / docs inside workflow.  \n\n\n## Quick Setup Guide\n\ud83d\udc49 [Demo & Setup Video](https://drive.google.com/file/d/1PLFPHSXQ-DaNAKeBQv7G9SzaXT0c3hRt/view?usp=sharing)\n\ud83d\udc49 [Course](https://www.udemy.com/course/n8n-automation-mastery-build-ai-powered-enterprise-ready/?referralCode=2EAE71591D3BEB80F2CC)"
      },
      "typeVersion": 1
    },
    {
      "id": "fa8c0a9a-ba60-49d7-acf0-a41e54cc995c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        768,
        -432
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "4bf93051-3d43-478c-967e-5fb79d333a24",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -528
      ],
      "parameters": {
        "color": 6,
        "width": 838,
        "height": 352,
        "content": "## \ud83d\udce5  INPUT & IMAGE PREPARATION\nThis section collects the required inputs and prepares images for AI processing.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "670f8a87-d6f5-4a93-9f0a-01690ff4e008",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -528
      ],
      "parameters": {
        "color": 6,
        "width": 646,
        "height": 352,
        "content": "## \ud83e\udde0  PROMPT ENGINEERING & AI GENERATION\nThis section constructs the instructions and generates the new advertisement.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f36ee66f-204f-4fc5-899c-f3edd232610e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -528
      ],
      "parameters": {
        "color": 6,
        "width": 678,
        "height": 352,
        "content": "## \ud83d\udce6 RESULT PROCESSING & OUTPUT\nThis section processes the generated image and prepares the final result.\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9203cce4-25bf-4ef0-8a54-ec4ffa1a1106",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "set_result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_image": {
      "main": [
        []
      ]
    },
    "set_result": {
      "main": [
        [
          {
            "node": "get_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
          }
        ]
      ]
    },
    "download_image": {
      "main": [
        [
          {
            "node": "convert_ad_image_to_base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generate_ad_image": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "generate_ad_image_prompt": {
      "main": [
        [
          {
            "node": "generate_ad_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "convert_ad_image_to_base64": {
      "main": [
        [
          {
            "node": "build_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "convert_product_image_to_base64": {
      "main": [
        [
          {
            "node": "download_image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This n8n workflow automates “cloning” a competitor ad style and re-generating it using your product image. A user uploads your product image and provides a competitor ad URL via a form trigger; the workflow downloads both images, converts them to inline/base64 parts, builds a…

Source: https://n8n.io/workflows/13209/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

🤹🤖 This workflow (AI Document Generator with Anthropic Agent Skills and Uploading to Google Drive) automates the process of generating, downloading, and storing professionally formatted files (PDF, DO

HTTP Request, Form Trigger, Google Drive
AI & RAG

Transform podcasts and other videos into captivating, fully optimized YouTube Shorts with this all-in-one automation solution—designed for content creators who repurpose engaging clips. By leveraging

Form Trigger, HTTP Request, YouTube
AI & RAG

Who this is for

YouTube, Form Trigger, Google Sheets +2
AI & RAG

works with selfhosted Supabase

Execute Workflow Trigger, Form Trigger, HTTP Request
AI & RAG

🎯 Create viral TikToks, Shorts, Reels, podcasts, and ASMR videos in minutes — all on autopilot.

OpenAI, HTTP Request, Form Trigger +7