Viral Reel Script Generator using Apify and GPT-4 - n8n Workflow

Automate content creation by scraping trending Instagram Reels, transcribing them, and generating unique viral video scripts using an n8n workflow leveraging GPT-4 and Apify for maximum engagement.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content Creators & Influencers: Users who need a constant supply of high-potential, proven video scripts based on current trends. Social Media Marketing Agencies: Firms looking to automate content trend analysis and script drafting for multiple clients. n8n Automation Specialists: Users interested in advanced examples of using the n8n node ecosystem for data extraction, AI analysis, and complex looping. Growth Hackers: Professionals who rely on data-driven script development for platform growth.

Overview

Generating consistent, high-performing short-form video content (Reels, TikToks) requires constant monitoring of trends and analyzing successful structures. This sophisticated n8n workflow solves this pain point entirely. It utilizes an n8n trigger form to start the process, automatically identifies trending reels based on popularity and recency using Apify, and then employs a detailed LangChain AI Agent powered by GPT-4 to analyze the underlying structure of the original video transcript.

This robust n8n workflow ensures that every generated script mimics the proven engagement pattern, pacing, and tone of a successful viral reel, but applies it to a completely new topic. By structuring the automation this way, users gain a powerful content creation advantage. This n8n template demonstrates advanced data flow control and external API integration within the n8n environment.

How it Works

This comprehensive n8n workflow executes in four main stages, starting with a custom n8n trigger:


  1. Initiation and Scraping: The automation starts via the On form submission n8n trigger, where the user provides a target hashtag and the desired number of reels to scrape. The Scrape Hashtag n8n node uses the Apify API to pull relevant Instagram data.

  2. Filtering and Storage: The Filter out from list n8n node enforces trend criteria, ensuring only recent (last 7 days) videos with high engagement (over 1000 likes) proceed. This filtered data is immediately logged into a Google Sheet using the Add to the sheet n8n node.

  3. Transcription and Analysis Loop: The Loop Over Items node initiates batch processing for each trending reel. Inside the loop, the Transcribe Video n8n node uses another Apify actor to generate a transcript from the reel's URL. The transcript is saved back to the Google Sheet using the Update sheet n8n node. The AI Agent n8n node, configured with the OpenAI Chat Model (GPT-4), receives the transcript and analyzes its structure (hooks, pacing, CTA). It then generates a new, original script using the same successful structure. The new AI-generated script is finally appended to the Google Sheet using the Add AI script n8n node.

  4. Reporting: Once the batch processing is complete, the flow exits the loop. The Summarize n8n node counts how many scripts were successfully generated. This final count is used by the Send a message (Gmail) n8n node to deliver an automated completion report to the user, confirming the execution of the n8n workflow.

Installation Guide

To deploy this powerful n8n workflow, follow these setup steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n canvas using the 'New' menu -> 'Import from JSON'.

  2. External Credentials: This n8n template requires several credentials:

Apify API Key: You must create an Apify account and input your API key into both the 'Scrape Hashtag' and 'Transcribe Video' HTTP Request n8n nodes, replacing the placeholder text [your api key]. OpenAI API Key: Configure the API key in the 'OpenAI Chat Model' n8n node credentials. Google Sheets: Authenticate your Google Sheets credentials and ensure the 'Add to the sheet', 'Update sheet', and 'Add AI script' n8n nodes are linked to the correct Google Document ID and sheet name. A template sheet is recommended for structure. Gmail (Optional): Set up the Gmail n8n node credentials for the final reporting step.

  1. Activate: Save and activate the n8n workflow. Access the webhook URL provided by the 'On form submission' n8n trigger to start generating scripts.

Node Details

On form submission (n8n trigger): This initial n8n trigger creates a custom web form that allows users to input the target Hashtag (e.g., #aiautomation) and the number of reels to scrape. This node acts as the entry point for the n8n automation. Scrape Hashtag (HTTP Request n8n node): Calls the Apify Instagram Reels scraper endpoint. Function: Collects reel metadata based on the user's input. Key Configuration: Uses expressions to dynamically set the hashtags and resultsLimit from the n8n trigger form data. Requires Apify authorization header. Filter out from list (Filter n8n node): Ensures data quality and relevance. Function: Filters content to be both popular (likesCount > 1000) and recent (timestamp within the last 7 days). Add to the sheet / Update sheet / Add AI script (Google Sheets n8n node): Three separate Google Sheets nodes manage data persistence. Function: Initially appends filtered data, then updates the row with the transcribed text, and finally updates it again with the AI-generated script. Key Configuration: Uses the url as the matching column for update operations (appendOrUpdate). Transcribe Video (HTTP Request n8n node): Calls the Apify video transcription service. Function: Converts the audio of the viral video into text for AI analysis. AI Agent (Langchain n8n node): The core intelligence of this n8n workflow. Function: Uses a highly customized system prompt to analyze the input transcript's structure and generate a new, unique script while preserving the original’s engagement pattern. OpenAI Chat Model (Langchain n8n node): Provides the LLM backend for the AI Agent. Key Configuration: Set to use a gpt-4.1-mini model, ensuring high-quality, structured output. Summarize (n8n node): Counts the successful outputs. Function:* Calculates the total number of new scripts generated, preparing the final metric for the report.

Related n8n Workflows

Free

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

AI Automation specialist with 4+ years experience.

Featured*