Creating viral short-form videos by hand takes hours — filming, editing, writing captions, uploading. This n8n viral shorts automation replaces every manual step. First, you add a subject to a Google Sheet. Next, the workflow generates a hyper-realistic AI image with Kie AI, turns it into a motion video using Google Veo 3, writes an optimized YouTube title and hashtags with Claude AI, and publishes the final video directly to your YouTube channel. As a result, you get a fully automated content pipeline that runs without you touching a single tool.
Prefer to skip the build? Grab the ready-made template and start publishing AI shorts in under 15 minutes.
What You Will Build
- You add a subject keyword to a Google Sheet row with Status set to
pending— for example, rusted wrench. - An AI agent generates a detailed image prompt: a hyper-realistic macro photo of the rusted object with a hand holding a spray bottle, foam reacting on contact.
- A second AI agent turns that image prompt into a video prompt describing the full transformation sequence — rusted to clean chrome in 6 to 9 seconds.
- Kie AI generates the image, then uses it as a reference frame to generate the video with Google Veo 3 at 9:16 aspect ratio.
- Claude AI writes a YouTube title (under 46 characters) and five hashtags optimized for the subject.
- The video binary is downloaded, uploaded to YouTube as a public Short, and added to your playlist.
- The Google Sheet row updates to
Video Publishedwith the exact publish timestamp.
How This n8n Viral Shorts Automation Works
The workflow uses two parallel polling loops to handle AI generation reliably. Image generation and video generation both take time — sometimes 30 seconds, sometimes several minutes. Instead of timing out, each loop checks the API status every 30 seconds and routes on the result: success moves forward, still generating loops back, and failure writes an error to the sheet.
What You Will Need
- n8n — self-hosted or n8n Cloud (v1.30+). See the n8n hosting documentation for setup options.
- Kie AI account — for image generation (nano-banana-pro model) and video generation (Veo3 Fast). See the Kie AI API documentation.
- OpenRouter account — to call Claude 3.7 Sonnet for prompt generation and caption writing.
- Google Sheets — one spreadsheet with the 7-column schema shown below.
- YouTube channel — with a YouTube Data API v3 OAuth2 credential and a playlist ID to publish into.
- Google account — connected in n8n via OAuth2 for Google Sheets access.
Estimated build time: 60 minutes from scratch, or under 15 minutes with the ready-made template.
Part 1 — Picking the Subject and Generating Prompts
Step 1 — Manual Trigger and Get Pending Row
The workflow starts with a Manual Trigger — you click Execute in n8n when you want to publish a new Short. First, it reads the Google Sheet and finds the first row where Status = pending. That row contains one field: objects — a plain text subject like rusty bolt, corroded pipe fitting, or old iron padlock. This single word drives everything that follows.
// Google Sheets row — what the workflow reads
{
"row_number": 3,
"objects": "rusted wrench",
"Image url": "",
"Video Url": "",
"Status": "pending",
"Video Title": "",
"Video Hashtags": "",
"Youtube Status": ""
}
Tip: You can batch-add subjects to the sheet in advance. The workflow picks exactly one row per execution, so running it once per day keeps a steady publishing cadence without any extra configuration.
Step 2 — Image Prompt Agent
The first AI Agent node receives the object name and generates a detailed image prompt. The system prompt enforces a very specific visual style: ultra-realistic macro photography, a rusted object with thick orange corrosion, one adult human hand holding a clear plastic spray bottle with blue liquid, the trigger actively pressed, and a foam reaction forming where the spray hits. These constraints are non-negotiable in the prompt — they exist to produce consistent, high-quality results that look real rather than generated.
For example, given the input rusted wrench, the agent returns a prompt like:
Ultra-realistic macro photograph of an extremely rusted adjustable wrench on a concrete
workshop floor. Natural daylight, shallow depth of field. Thick orange corrosion, deep
pitted metal surface, rust flakes visible. One realistic adult human hand holding a clear
plastic spray bottle with blue cleaning liquid. Trigger spray head visible, finger pressing
trigger, spray stream connected from nozzle to wrench surface. White-blue foam building on
contact. Hyper-realistic 4K, cinematic macro shot. No logos, no text.
Step 3 — Video Prompt Agent
The second AI Agent takes the image prompt as input and generates a video prompt. The video prompt describes motion — not a static scene. It specifies the same hand, bottle, location, and object, then adds a mandatory transformation sequence: fully rusted object shown, hand enters frame, trigger pressed, spray hits, foam builds rapidly, rust dissolves gradually, clean chrome finish revealed, water droplets drip. This sequence is what makes the videos satisfying to watch and naturally viral.
Note: The system prompt explicitly bans jump cuts and magical transitions. Veo 3 can produce unrealistic glowing effects if the prompt doesn’t constrain it. The “gradual dissolving” instruction is what keeps the physics-based animation believable.
Part 2 — Generating the Image with Kie AI
Step 4 — Generate Image (Kie AI)
This node posts to the Kie AI /jobs/createTask endpoint. It uses the nano-banana-pro model — Kie’s image generation model — with a 9:16 aspect ratio (vertical, for Shorts), 1K resolution, and PNG output. The image prompt from the previous agent goes directly into the input.prompt field. In return, Kie AI gives you a taskId which the polling loop uses to check completion status.
// Generate Image request body
{
"model": "nano-banana-pro",
"callBackUrl": "YOUR_CALLBACK_URL",
"input": {
"prompt": "{{ $('Image Prompt').item.json.output }}",
"aspect_ratio": "9:16",
"resolution": "1K",
"output_format": "png"
}
}
// Kie AI response
{
"data": { "taskId": "img_task_abc123" }
}
Step 5 — Image Polling Loop (Get Image URL + Switch2)
Generating an image takes between 15 and 90 seconds depending on server load. Instead of waiting a fixed amount of time and hoping it’s done, the workflow polls every 30 seconds. The Get Image URL node calls /jobs/recordInfo?taskId=... and the Switch2 node reads $json.data.state. There are four routes: success moves forward and saves the image URL to the sheet, waiting and generating both loop back through a 30-second Wait node, and fail writes “Failed To Generate” to the sheet and stops.
On success, the image URL is extracted from JSON.parse($json.data.resultJson).resultUrls[0] and written to the Image url column. This URL becomes the reference frame for the video generation step.
Tip: You can monitor generation progress in real time by opening your Kie AI dashboard while the workflow runs. The status field cycles through waiting, generating, then success — exactly matching the Switch2 routes.
Part 3 — Generating the Video with Veo 3
Step 6 — Generate Video (Kie AI Veo3 Fast)
With the image URL saved, the workflow posts to Kie AI’s /veo/generate endpoint. The request sends the video prompt, the generated image URL as a reference frame, and specifies veo3_fast as the model with a 9:16 vertical aspect ratio. The generationType is REFERENCE_2_VIDEO — this tells Veo 3 to animate from the reference image rather than generating from text alone. As a result, the video visually matches the generated image, keeping the object and hand consistent.
// Generate Video request body
{
"prompt": "{{ $('Video Prompt').item.json.output }}",
"imageUrls": ["{{ $json['Image url'] }}"],
"model": "veo3_fast",
"aspect_ratio": "9:16",
"seeds": 12345,
"generationType": "REFERENCE_2_VIDEO"
}
Note: The seeds value of 12345 is fixed in the template. Using a consistent seed helps produce repeatable visual styles across different subjects. Change it to a random value if you want more visual variety between videos.
Step 7 — Video Polling Loop (Get Video + Switch)
Video generation takes longer than image generation — typically 2 to 5 minutes. The video polling loop uses the same pattern as the image loop but reads $json.data.successFlag as a number instead of a state string. A value of 1 means success, 0 means still generating, 2 is another in-progress state, and 3 means generation failed. On success, the video URL is extracted from data.response.resultUrls[0] and written to the sheet with Status = Video Generated.
Part 4 — Writing the Caption and Publishing to YouTube
Step 8 — Video Caption (OpenRouter + Claude)
Once the video URL is saved, the workflow calls OpenRouter with the object name as a keyword. Claude 3.7 Sonnet acts as a social media copywriter and returns a YouTube title (maximum 46 characters) followed by five hashtags separated by a blank line. No labels, no emojis, no markdown bold — just clean copy ready for use as a video title and description.
Step 9 — Separate Title From Tags (Code Node)
The Code node splits Claude’s response into two separate fields using a blank line as the delimiter. The first block becomes Title and the second becomes hashtags. Both fields are then written to the Google Sheet in the Video Title and Video Hashtags columns.
const content = $json.choices[0].message.content || "";
// Split on blank line between title and hashtags
const parts = content.split(/\n\s*\n/);
const title = parts[0] ? parts[0].trim() : "";
const hashtags = parts[1] ? parts[1].trim() : "";
return [{ json: { Title: title, hashtags: hashtags } }];
// Resulting fields written to Google Sheets
{
"Title": "Rust Remover Works Instantly on Old Wrench",
"hashtags": "#rustremoval #rustcleaning #satisfyingvideo #restoration #aivideo"
}
Step 10 — Download Video Binary and Upload to YouTube
An HTTP Request node downloads the video binary from the Kie AI CDN URL stored in the sheet. The YouTube Upload node then receives the binary directly, using the saved Video Title as the title and Video Hashtags as the description. The video publishes as public, notifies subscribers, and is tagged with a fixed set of niche-relevant tags covering rust removal, AI video, ASMR, and satisfying content. After a 10-second wait, the Add to Playlist node links the uploaded video to your channel’s Shorts playlist.
Tip: The YouTube category is set to 22 (People and Blogs) in the template. For a rust cleaning channel, category 26 (Howto and Style) may rank better in search. Change the categoryId value in the Upload node parameters.
Step 11 — Update YouTube Status in Google Sheets
Finally, the Add to Playlist response includes contentDetails.videoPublishedAt — the exact UTC timestamp when the video went live. The last Google Sheets node writes this to the Youtube Status column as Video Published — 2026-03-18T14:30:00Z. This gives you a complete audit trail in the sheet: object name, image URL, video URL, title, hashtags, and publish time — all in one row.
The Data Structure — Google Sheets Schema
Create a spreadsheet named Viral with one tab named Sheet1. The column names below are case-sensitive — the workflow uses exact string matching on all update operations.
| Column Name | Type | Example Value | Description |
|---|---|---|---|
objects | Text | rusted wrench | The subject keyword you provide. Drives all AI prompt generation. |
Image url | Text | https://cdn.kie.ai/…/output.png | Filled automatically after image generation succeeds. Set to “Failed To Generate” on failure. |
Video Url | Text | https://cdn.kie.ai/…/video.mp4 | Filled automatically after video generation succeeds. Set to “Failed To Generate” on failure. |
Status | Text | pending / Video Generated | Set to pending by you. Updated to Video Generated by the workflow after the video URL is saved. |
Video Title | Text | Rust Remover Works Instantly on Old Wrench | AI-generated YouTube title, max 46 characters. |
Video Hashtags | Text | #rustremoval #rustcleaning … | Five AI-generated hashtags, used as the YouTube video description. |
Youtube Status | Text | Video Published — 2026-03-18T14:30:00Z | Written automatically when the video is added to your YouTube playlist. |
Note: Start each new subject by adding a row with the objects field filled in and Status set to pending. Leave all other columns empty — the workflow fills them in automatically as it runs.
Full n8n Viral Shorts Automation Flow — End to End
Testing Your n8n Viral Shorts Automation Workflow
- Add one row to your Google Sheet with
objects = rusty screwdriverandStatus = pending. Leave all other columns empty. - In n8n, open the workflow and click Execute workflow. Watch the execution panel — nodes should light green in sequence.
- After the Image Prompt and Video Prompt agents run, check the output panel to confirm both prompts contain the mandatory elements: hand, spray bottle, foam, transformation sequence.
- After the image polling loop completes, check your Google Sheet. The
Image urlcolumn should contain a valid Kie AI CDN URL ending in.png. - Wait for the video polling loop to finish (2 to 5 minutes). Confirm
Video Urlcontains an MP4 URL andStatusshowsVideo Generated. - After the caption step, verify
Video Titleis under 46 characters andVideo Hashtagscontains exactly five hashtag terms. - After the YouTube upload, open your YouTube Studio and confirm the video appears as a public Short with the correct title, description, and playlist assignment.
- Confirm the
Youtube Statuscolumn showsVideo Publishedwith a timestamp.
| Problem | Likely Cause | Fix |
|---|---|---|
| Image polling never exits the loop | Kie AI task is stuck or the API key has no image generation credits | Check your Kie AI dashboard for the task status. Verify your API key has sufficient credits for the nano-banana-pro model. |
| Image URL saved as undefined | The resultJson field is not JSON-parseable in some API responses |
Add a try-catch around the JSON.parse in the Update row expression, or use $json.data.resultUrls[0] as a fallback path. |
| Video generation fails immediately (successFlag=3) | The image URL passed to Veo 3 is not publicly accessible | Open the image URL from the sheet in a browser. If it requires authentication, switch to Kie AI’s public CDN delivery option in your account settings. |
| YouTube upload returns 403 Forbidden | OAuth2 token expired or YouTube Data API not enabled in Google Cloud Console | Reconnect the YouTube OAuth2 credential in n8n. In Google Cloud Console, confirm the YouTube Data API v3 is enabled for your project. |
| Title is longer than 46 characters | Claude occasionally exceeds the character limit on certain keywords | Add a character truncation step after the Code node: title.substring(0, 46). Alternatively, strengthen the system prompt by adding “The title MUST be 46 characters or fewer — count carefully.” |
| Google Sheet not updating | Column name mismatch — the field names are case-sensitive | Verify the headers match exactly: objects, Image url, Video Url, Status, Video Title, Video Hashtags, Youtube Status. |
Frequently Asked Questions
Can I use this n8n viral shorts automation for subjects other than rusted objects?
Yes, but the AI prompt agents are currently tuned for the rust-cleaning niche specifically. The system prompts mention spray bottles, foam, corrosion, and chrome finishes. To use a different niche — for example, before-and-after car detailing or dirty sneaker cleaning — rewrite the Image Prompt and Video Prompt system prompts to describe your subject’s transformation sequence. The rest of the workflow is fully niche-agnostic and does not need changes.
How much does it cost to generate one video?
Costs depend on your Kie AI plan and OpenRouter usage. Image generation with nano-banana-pro typically costs a few cents per image. Video generation with Veo3 Fast is more expensive — around $0.10 to $0.30 per video depending on length. Claude 3.7 Sonnet via OpenRouter adds less than $0.01 per caption. For a channel publishing one video per day, total monthly API costs are typically under $15.
Why does the workflow use a manual trigger instead of a schedule?
The manual trigger is the safest starting point. Video generation can take 2 to 5 minutes, and if a scheduled trigger fires while a previous execution is still running, you can end up with duplicate uploads. Once you are confident the workflow runs cleanly end to end, replace the Manual Trigger with a Schedule Trigger set to fire once per day at a time that suits your posting schedule.
What happens if image generation fails?
The Switch2 node routes the fail state to an Update IMG status node, which writes “Failed To Generate” to the Image url column. The workflow then stops — it does not proceed to video generation. The row remains in the sheet with its original Status = pending, so you can manually re-trigger the workflow to retry. For production use, consider changing the status to img_failed and adding a new filter that picks up both pending and img_failed rows.
Can I publish to TikTok or Instagram Reels in addition to YouTube?
The video is generated in 9:16 format, which is correct for all three platforms. After the HTTP Request node downloads the binary, you can add parallel branches: one for YouTube (already built), one for Instagram Reels via the Facebook Graph API, and one for TikTok via their Content Posting API. The binary is the same file — just route it to multiple upload nodes. This is the same pattern used in our Social Media Automation workflow.
How do I change the video model or aspect ratio?
Open the Generate Video node and edit the JSON body directly. Change "model": "veo3_fast" to "veo3" for higher quality at slower speed, or adjust "aspect_ratio" from "9:16" to "16:9" for standard landscape YouTube videos. For landscape videos, also update the Image Prompt system prompt to request a 16:9 aspect ratio — otherwise the reference image and video will have mismatched dimensions.
Get the n8n Viral Shorts Automation Template
Download the ready-to-import workflow JSON and the Google Sheets template with all 7 columns pre-configured — start publishing AI-generated Shorts to YouTube today.
Get the TemplateInstant download — works on n8n Cloud and self-hosted
What to Build Next
- Add a Schedule Trigger — replace the manual trigger with a daily schedule so the workflow publishes one new Short every day without any manual intervention.
- Expand to multiple niches — duplicate the workflow and change the Image and Video Prompt system prompts for a different transformation niche: car detailing, sneaker cleaning, or power washing.
- Add Instagram Reels publishing — after the HTTP Request node downloads the binary, add a Facebook Graph API branch to post the same 9:16 video as an Instagram Reel in the same execution.
- Add a Telegram notification — wire a Telegram node at the end to send yourself a message with the video title and YouTube URL every time a new Short goes live.
- Browse more automation guides on the EasyWorkflows n8n blog.