Automated E-Commerce Ad Creative Generation with Gemini API - n8n Workflow

Deploy this robust n8n workflow to generate unlimited AI-powered e-commerce ad creatives by blending product and influencer images using the Gemini API. This n8n templates solution streamlines marketing asset creation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

E-commerce marketers needing rapid, scaled ad creative production.
Agencies managing social media campaigns for multiple clients and requiring fast A/B testing assets.
Users looking for advanced examples of using the n8n node for HTTP requests with binary data and generative AI.
Anyone seeking powerful n8n templates for complex creative asset automation.

Overview

This advanced n8n workflow solves the tedious problem of generating numerous marketing variations suitable for modern social media campaigns. By utilizing the Google Gemini API (accessed via a dedicated HTTP Request n8n node), the workflow takes a single product image uploaded by the user and iteratively places it into contexts featuring various 'influencer' images stored in Google Drive. The output is a multitude of realistic, scenario-based ad creatives, drastically speeding up content creation and testing cycles. This powerful n8n solution is highly optimized for achieving high throughput for your creative assets, providing significant value over manual editing.

How it Works

The entire process is initiated via a public n8n trigger form.


  1. Trigger & Product Capture: The n8n workflow starts with the formtrigger n8n trigger, where the user uploads the primary product image.

  2. Product Preparation: The uploaded product image is immediately converted to a Base64 string by the productimagetobase64 n8n node, preparing it for the AI API call.

  3. Influencer List Retrieval: The n8n workflow lists all available 'influencer' reference images from a designated Google Drive source folder using the listinfluencerimages n8n node.

  4. Iteration: The iterateinfluencerimages n8n node initiates a loop, ensuring the rest of the n8n workflow processes each influencer image sequentially, creating a distinct ad creative for every reference photo.

  5. Data Preparation (Loop): Inside the loop, the current influencer image is downloaded and converted to Base64 format.

  6. AI Image Generation: The core functionality resides in the generateimage n8n node (an HTTP Request to the Gemini API). It sends a multi-part JSON payload containing both the product Base64 data and the influencer Base64 data, combined with a precise text prompt instructing the AI to composite the product into the influencer's scene (e.g., holding the product at a café).

  7. Result Conversion & Output: The resulting Base64 image data from the Gemini API response is extracted by the setresult n8n node, converted back into a proper binary file using the getimage n8n node, and finally uploaded to a target Google Drive folder using the uploadimage n8n node, completing one loop cycle of the n8n workflow.

Installation Guide

To utilize this powerful n8n templates solution, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON code and import it directly into your n8n instance using the 'New' > 'Import from JSON' option.

  2. Google Drive Credential Setup: Ensure you have Google Drive OAuth2 API credentials configured. These must be linked to the listinfluencerimages, downloadinfluencerimage, and uploadimage n8n node instances.

  3. Gemini API Credential Setup: Set up an HTTP Header Auth credential for the generateimage n8n node. This requires using your Google Gemini API Key, often configured as a Bearer Token or custom header.

  4. Configure Source Folder: Update the listinfluencerimages n8n node parameter to specify the Folder ID of your Google Drive folder containing the influencer reference photos.

  5. Configure Destination Folder: Update the upload_image n8n node parameter to specify the target Google Drive Folder ID where the final generated ad creative images will be saved.

  6. Activate: Save and activate the n8n workflow to make the form available for input via the unique webhook URL.

Node Details

formtrigger (n8n trigger): The entry point, initiating the n8n workflow upon submission of the product image via its public URL. Key Configuration: Set up to receive a required file upload.
product
imagetobase64 (Extract From File n8n node): Essential file handling n8n node. It converts the incoming binary product image into a Base64 string property named Image, which is required for multimodal AI input.
listinfluencerimages (Google Drive n8n node): Retrieves the list of file metadata (IDs) for all reference images stored in the specified source folder. It uses returnAll to get the full list.
iterateinfluencerimages (Split In Batches n8n node): A critical core logic n8n node. It manages the looping structure, ensuring that the image generation steps run once for every influencer file identified.
generateimage (HTTP Request n8n node): The key generative n8n node. It targets the Google Gemini API (gemini-2.5-flash-image-preview:generateContent) using a custom JSON body that meticulously embeds two Base64 images and a contextual prompt to guide the composition.
set
result (Set n8n node): Handles data manipulation. It extracts the deeply nested Base64 encoded image data from the complex AI response structure.
getimage (Convert To File n8n node): Converts the Base64 string output from the AI back into a standardized binary file format, ready for storage.
upload
image (Google Drive n8n node): The final action n8n node. It takes the newly generated ad creative binary file and uploads it to the configured destination folder with a dynamic filename based on the iteration count.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

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!

Featured*