Feb 13, 20269 min read

Building an AI-Powered Ad Generation System for Businesses ๐Ÿ’ธ

An end-to-end n8n workflow that turns a product name, description, and a couple of photos into a fully edited, titled, thumbnailed video ad โ€” uploaded straight to YouTube, no manual editing.

AI Automationn8nGenerative AIMarketing TechWorkflow Automation
Dark workflow diagram behind the title 'AI Powering Viral Ads: A Deep Dive into Automation โ€” Unlock limitless creativity with intelligent workflows'

In today's digital landscape, speed wins. Brands that can generate creatives, videos, thumbnails, and campaign-ready assets faster outperform competitors.

So I built an end-to-end AI ad-generation automation system that produces a viral ad video for a product โ€” complete with a suitable description, hashtags, title, and more โ€” and pushes it directly to YouTube. Here's an example it produced:

A Nike shoe ad, generated end to end by the workflow below โ€” image, video, title, description, and thumbnail included.

This project shows how much of the manual production work in marketing โ€” creative direction, editing, thumbnail design, metadata โ€” AI and automation can take off someone's plate. Here's how it's built ๐Ÿ˜Ž

The workflow breaks down into 5 stages:

  • User input and processing
  • Image generation for the ad video
  • Video ad generation
  • Video title, description & thumbnail creation
  • Video upload

Stage 1: User input and processing

n8n workflow diagram: On form submission โ†’ Edit Fields โ†’ Split Out โ†’ Upload Images to Cloudinary โ†’ Aggregate โ†’ Analyze image โ†’ Save Product Information
Stage 1: capturing and processing the user's product input.

This stage takes the user's input, processes and analyzes it, and saves it to Google Sheets for reference. It starts with the user submitting some basic product information:

  • Product name
  • Company name
  • Product description
  • Product image(s)
Sample form submission showing Product Name 'Nike Tiempo Maestro Elite', Company Name 'Nike', a product description, and two uploaded product images
A sample form submission โ€” the raw input the whole pipeline runs on.

The fields get renamed via Edit Fields and Split Out nodes, and the images get uploaded to Cloudinary to get a URL for each one. Those URLs then get passed through an Analyze node to produce an image description.

n8n Analyze image node configured with an OpenAI account, analyzing image URLs to produce a text description
The Analyze node in n8n, turning each product image into a text description.

The results get pushed to Google Sheets for the record, and it's on to the next stage.

Stage 2: Image generation for the ad video

n8n workflow diagram: Generate Image Prompt โ†’ Create Image โ†’ Wait 15s โ†’ Get Image Status โ†’ If (loop) โ†’ Download Edited Image
Stage 2: turning the product info into a prompt, then a generated image.

This stage starts with an Image Prompt AI Agent that learns from the user-provided information โ€” including the images โ€” and produces a prompt to build the ad around. Its system message looks like this:

Image Prompt Builder โ€” system message
text
** Role & Purpose **
You are a UGC Image Prompt Builder.
Your purpose is to generate one concise, natural, and realistic image prompt (โ‰ค120 words) from a given product or reference image, simulating authentic UGC-style photography.

** Capabilities **
- Output only one JSON object with the key `image_prompt`.
- Write the prompt in a casual, unstaged, lifelike tone.
- Always include 2-3 camera cues (e.g., phone snapshot, handheld framing, off-center composition, natural indoor light, soft shadows, slight motion blur, auto exposure, mild grain).
- Embrace realism and imperfections (wrinkles, stray hairs, skin texture, clutter, smudges).
- Preserve packaging/text exactly as visible. Never invent claims, numbers, or badges.
- Default people to diverse appearances (gender/ethnicity), ages 21-38.
- Default setting: everyday spaces (home, street, store, gym, office).
- Ensure JSON only, no commentary, metadata, or extra keys.

** Interaction Style **
- Casual and natural, like describing a real snapshot.
- Lifelike, unpolished, unstaged.
- No dialogue or script writing. Only describe the visual scene.

** Example Output **
{
  "image_prompt": "a young adult casually holding a skincare tube near a bathroom mirror; action: dabs small amount on the back of the hand; mood: easy morning; setting: small apartment bathroom with towel on rack and toothbrush cup; style/camera: phone snapshot, handheld framing, off-center composition, natural window light, slight motion blur, mild grain; colors: soft whites and mint label; text accuracy: keep every word on the tube exactly as visible, no added claims"
}

The image itself is generated with the Nano Banana image-to-image model on Fal.ai. A polling loop acts as a safety net โ€” if the image isn't ready within the expected window, it retries fetching the generation status instead of failing outright. Here's what it produced for the Nike example:

AI-generated UGC-style photo of Nike Tiempo Maestro Elite football boots on grass, next to their shoe box
The image Nano Banana generated on Fal.ai, from the prompt above.

Stage 3: Video ad generation

n8n workflow diagram: Generate Video Script โ†’ Code in JavaScript โ†’ Generate Video โ†’ Wait 120s โ†’ Get Video Status โ†’ If (loop) โ†’ Download Video
Stage 3: turning the generated image into a video ad.

This stage outputs a video based on everything the workflow has built so far. Like Stage 2, it starts by having an AI Agent build a video prompt, and a Code node stringifies the agent's output so it's safe to pass downstream:

javascript
const structuredPrompt = $input.first().json.output.final_prompt;
return {
  json: {
    prompt: JSON.stringify(structuredPrompt), // this escapes it correctly!
  }
};

That prompt goes to Fal.ai's API to generate the video from the image, using the veo3.1 fast model โ€” with the same Wait/If polling pattern from Stage 2 keeping track of the API response. Once it's ready, the video is downloaded via the GET request documented for that model's API.

Stage 4: Video title, description & thumbnail creation

n8n workflow diagram: Generate Video Description, Title & Thumbnail Prompt โ†’ Create Thumbnail โ†’ Wait 15 โ†’ Get Thumbnail Status โ†’ If โ†’ Download Thumbnail โ†’ Analyze thumbnail โ†’ Is Thumbnail valid?
Stage 4: generating the title, description, and a validated thumbnail.

This stage produces the video's title, description, and a thumbnail prompt, from an AI Agent outputting this exact shape:

json
{
  "video_title": "",
  "video_description": "", // with hashtags
  "thumbnail_prompt": ""
}

The thumbnail itself is generated with Nano Banana again, then passed through OpenAI's Analyze node to check whether it actually matches the product and meets expectations:

n8n expression checking a generated thumbnail image against the video title, description, and product name/company name for quality and brand consistency
The thumbnail-validation prompt โ€” checking quality, text legibility, and product accuracy before it ships.

Stage 5: Video upload ๐ŸŽฅ

n8n workflow diagram: Get Video Binary โ†’ Upload a video โ†’ Get Thumbnail binary โ†’ Thumbnail Upload โ†’ Update row in sheet
Stage 5: pushing the finished video and thumbnail to YouTube.

The final stage downloads the video as binary so it can be pushed to a YouTube channel. Both the video and the thumbnail need converting to binary before upload. Setting the thumbnail specifically needs a direct POST request โ€” n8n doesn't support that natively:

  • Request type: POST
  • Credentials type: YouTube OAuth2 API (predefined credential type)
  • URL: https://www.googleapis.com/upload/youtube/v3/thumbnails/set?videoId=<VIDEO_ID>&uploadType=media
  • Headers: Content-Type: image/jpeg
  • Body: n8n Binary File โ€” data
Final generated YouTube thumbnail reading 'Glove-Like Grip' next to a Nike football boot on a stadium pitch
The final thumbnail this run produced, now live on the uploaded video.

Everything is written back to Google Sheets for the record โ€” and that's the full loop, from a product name and a couple of photos to a video ad, live on YouTube with its own title, description, and thumbnail.

Why this matters for businesses ๐Ÿ’ก

  • โœ… Generate 50+ ad creatives daily
  • โœ… Reduce production cost by 70%
  • โœ… Eliminate manual editing
  • โœ… Maintain brand consistency
  • โœ… Scale campaigns instantly
Animated waving robot mascot
That's the workflow โ€” from a product photo to a finished, uploaded ad.

Key takeaways

  • The pipeline chains together three separate generative models โ€” Nano Banana for images, veo3.1 for video, and an LLM agent for prompts/copy โ€” each with its own polling loop, rather than assuming any single call completes instantly.
  • A structured JSON contract between stages (image_prompt, then video_title/video_description/thumbnail_prompt) is what keeps five loosely-coupled n8n stages composable instead of one giant workflow.
  • Validating the generated thumbnail against the product before publishing (Stage 4's Analyze step) is what keeps this safe to run unattended โ€” it isn't just generate-and-ship.
  • Platform quirks still need manual workarounds even in a fully automated pipeline โ€” n8n has no native YouTube-thumbnail node, so that step is a raw authenticated POST request.

Written by Shubham Jain, Cloud Engineer at Newspresso Tech.

Want this kind of engineering on your infrastructure?