AI-generated content is dominating platforms like TikTok and Instagram, with videos such as Yeti clips, ASMR glass-cutting scenes, and even Stormtrooper-themed videos attracting millions of views daily. Many creators try to manually recreate these viral hits but often struggle to match the quality and engagement. However, there is a systematic way to reverse engineer these viral videos using automation tools.
If you're interested in building your own viral AI video series without guesswork, this guide will show you how to create a complete automation workflow. Using n8n, Apify (a web scraping platform), and Google Gemini, you can input any TikTok or Instagram video URL and get a detailed prompt back. This prompt can then be fed into AI video generators like Veo 3, enabling you to generate highly accurate viral video replicas that can later be customized.
Before diving into the technical details, consider joining our free AI Automation Community, where you can access this entire automation template and collaborate with others building AI-powered workflows.
Overview of the Viral Video Cloning Workflow
The core idea behind this automation is to take a viral video URL from TikTok or Instagram, analyze the video content deeply, and generate a precise AI prompt that replicates the original video. Here’s a step-by-step overview of the process:
- Input a Video URL: Paste the URL of any TikTok or Instagram video you want to clone.
- Video Source Detection: The system detects whether the URL is from Instagram or TikTok and routes the workflow accordingly.
- Scrape Video Data: Using Apify’s scraping actors, the system extracts video metadata and downloads the video file.
- Encode Video: The downloaded video is converted into a Base64 string to prepare it for AI analysis.
- Analyze Video with Google Gemini: The encoded video and a detailed analysis prompt are sent to Google Gemini’s API, which breaks down the video into precise components.
- Generate AI Prompt: Google Gemini returns a comprehensive generative manifest—a detailed prompt that AI video generators can use to create an almost exact replica of the original video.
- Output & Sharing: The final prompt is saved as a text file and shared via Slack for easy access and further editing.

Building the Base Prompt for Video Analysis
A critical part of this process is crafting a detailed prompt that instructs the AI on how to analyze and replicate the video. This prompt defines the AI’s persona and mission very precisely to avoid any interpretation or guesswork. Instead, the AI is tasked with transcribing reality into data, creating a shot-for-shot, motion-for-motion digital twin of the video.
The prompt sets the following:
- Persona: A digital twin architect and AI analyst with expertise in forensic video analysis and generative AI video synthesis.
- Objective: Break down the source video into quantifiable components and architect a flawless multi-part prompt for AI video generation.
- Scope: Layered analysis including global aesthetics, physics core, and per-shot deconstruction detailing camera angles, shot duration, framing, and subject actions.
This level of detail ensures the generated prompt leaves no room for creative interpretation, aiming for an exact replica when fed into AI video models such as Veo 3.

Scraping Video Data Using Apify
After defining the base prompt, the next step is to extract the necessary video data from the social media platform. This is done through Apify, a versatile web scraping platform that uses “actors” — mini-applications designed for specific scraping tasks.
For Instagram reels and TikTok videos, dedicated Apify actors are available:
- Instagram Reel Scraper: Extracts metadata such as captions, hashtags, and direct video download URLs from Instagram reels.
- TikTok Scraper: Retrieves similar data for TikTok videos, including video URLs, captions, and hashtags.
To set this up in your automation:
- Make an HTTP POST request to the corresponding Apify actor API endpoint.
- Pass the video URL as part of the request body.
- Configure authentication by adding your Apify API key in the request headers.
This process returns the direct video URL and metadata, which the automation uses to download and further process the video.

Encoding and Sending Video to Google Gemini API
Once the video is downloaded, it needs to be prepared for AI analysis. The automation converts the video file into a Base64 encoded string, which makes it possible to send the video inline within an API request.
Google Gemini’s API is then called with a POST request, passing two critical pieces of information:
- Encoded Video Data: The Base64 string representation of the video.
- Analysis Prompt: The detailed prompt built earlier that instructs Gemini on how to analyze and transcribe the video.
This inline video data approach simplifies the process compared to uploading a video file separately, which requires multiple API calls. It’s particularly effective for short-form videos like TikToks or Instagram reels.
To authenticate requests to Google Gemini, you need an API key set in the request headers with the name x-goog-api-key. This key is obtained from Google AI studio.

Using the AI-Generated Video Prompt
Google Gemini returns a generative manifest in response — a comprehensive AI prompt detailing every aspect of the original video scene. This prompt is designed to be fed directly into an AI video generator to recreate the viral content with high fidelity.
This output is saved as a text file and automatically shared to Slack for easy review and editing. From there, you can:
- Copy the prompt and paste it into AI video generators like Veo 3.
- Customize elements such as subjects, colors, or camera angles to create variations and build a viral video series.
This flexibility allows creators to rapidly produce multiple related AI videos based on a single viral template.

How to Access This n8n Automation Template
This entire automation workflow is available as a downloadable n8n template. By joining the AI Automation Mastery community, you gain free access to the JSON file that contains this workflow. You can import it directly into your n8n instance and start using it immediately.
Once imported, you can customize the workflow to fit your needs, whether that’s scraping videos from different sources or adjusting the video parameters for your own viral video series.
Next Steps
Cloning viral AI videos is no longer a guessing game. By combining n8n, Apify, and Google Gemini, you can automate the process of analyzing viral TikTok and Instagram videos and generate precise AI prompts to replicate them.
This method saves time and effort, allowing you to focus on creativity and scaling your content series. The automation extracts video data, encodes it, sends it for deep AI analysis, and returns a prompt ready for AI video generation — all with minimal manual input.