Automate AI Video Creation & Social Posting with n8n and Blotato

Save hours by automating AI video creation and publishing to 9 social platforms using Telegram, GPT-4, and Blotato in n8n. This workflow transforms Telegram prompts or images into engaging, captioned videos with music, then publishes them automatically across multiple channels.
telegramTrigger
httpRequest
openAi
+7
Learn how to Build this Workflow with AI:
Workflow Identifier: 1009
NODES in Use: telegramTrigger, code, if, telegram, httpRequest, wait, set, googleSheets, openAi, stickyNote

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Sarah, a digital marketing manager juggling content creation for multiple social media channels. Every day, she spends 4+ hours crafting short videos, writing captions, synchronizing music, and manually posting across platforms like Instagram, TikTok, and YouTube. Mistakes slip in due to manual copy-pasting, and engagement drops because videos lack consistent subtitles or compelling captions. Unreliable scheduling and disorganized media tracking compound her stress.

This exact scenario is what this intricate n8n workflow solves by fully automating video creation from AI prompts or images, crafting music and captions with GPT-4, and distributing content to 9 social sites via Blotato’s API — all triggered through Telegram.

2. What This Automation Does

This powerful automation in n8n serves as an end-to-end AI-driven social video pipeline that:

  • Listens for Telegram messages containing video prompts or images as triggers.
  • Generates AI-crafted videos either from text prompts or user-uploaded images.
  • Creates custom short music tracks aligned to the video theme using Piapi’s text-to-audio AI.
  • Produces catchy, contextual overlay text (subtitles) and social captions leveraging GPT-4 natural language generation.
  • Automatically merges visuals, voice-over, and captions into a polished video asset.
  • Saves metadata into Google Sheets for cataloging and tracking content performance.
  • Distributes the final video and captions across 9 major social media platforms including Instagram, YouTube, TikTok, Facebook, Twitter (X), LinkedIn, Threads, Bluesky, and Pinterest through Blotato’s API.
  • Notifies the content creator via Telegram with final video and details.

Thanks to this, Sarah saves at least 3 hours daily, eliminates human error, boosts engagement with styled captions, and scales social media presence without extra hires.

3. Prerequisites ⚙️

  • n8n Automation Platform account (self-hosting recommended for full control, consider Hostinger for hosting).
  • Telegram Bot Token and Telegram API set up for receiving messages and sending notifications. 📧
  • Blotato API key for video generation and publishing to multiple social accounts.
  • Piapi AI account for music and image-to-video generation.
  • OpenAI API key for GPT-4 text generation for scripts, captions, and SEO titles. 🔑
  • Google Sheets account with OAuth setup to save video metadata. 📊
  • Cloudinary account for temporary image hosting.

4. Step-by-Step Guide

Step 1 — Set up Telegram Trigger to Receive Video Prompts or Images

In n8n, navigate to Nodes > Add Node > Telegram Trigger. Input your Telegram bot credentials under telegramApi. Choose Updates: message to listen for new text or media messages from your Telegram chat.

When a message arrives, this node captures it as the workflow trigger. Visual cue: You should see incoming Telegram messages in the node’s execution pane when testing manually.

Common Mistake: Forgetting to enable updates or not using the correct bot token results in no trigger firing.

Step 2 — Extract and Clean the Prompt or Image Input with Code Node

Add a Code node to parse the Telegram message text or caption. Use this JavaScript code snippet to remove any “generate video” prefix and split input by commas into three variables: video prompt, caption idea, and music style.

const input = $input.first().json.message.text || $input.first().json.message.caption;

// Remove optional "generate video" prefix
const cleaned = input.replace(/^generate video[:]?/i, '').trim();

// Split by comma
const parts = cleaned.split(',').map(p => p.trim());

// Assign values even if missing
const videoPrompt = parts[0] || "";
const captionIdea = parts[1] || "";
const musicStyle = parts[2] || "";

return [
  {
    json: {
      videoPrompt,
      captionIdea,
      musicStyle
    }
  }
];

After running, the node outputs structured data your workflow uses downstream.

Common Mistake: If no input, following nodes will fail. Add an If condition to check input presence to avoid errors.

Step 3 — Check Input Type and Branch Workflow for Text vs Image

Add an If node configured with condition {{$node["Trigger Telegram Prompt or Image"].json.message.text != ""}} to detect if the trigger contains text or fallback to image processing path.

This separation ensures different video generation methods: text via Blotato template, image processed with Piapi for video.

Visual confirmation: Check which branch is executed based on your test inputs.

Step 4 — For Image Inputs, Download Image from Telegram

If image input, add a Telegram node set to Download File resource. Use the file ID from the Telegram message photo array (largest size usually at index 3) to fetch the image.

Follow with an HTTP Request node to extract the actual file URL from Telegram API using this URL pattern:

=https://api.telegram.org/file/bot_YOURTOKEN/{{ $('Download Image from Telegram').item.json.result.file_path }}

Replace YOURTOKEN with your bot token string.

The result is the public video source URL.

Common Pitfall: Forgetting to enable file download access permission in your bot or misusing file indexing may cause download failures.

Step 5 — Upload Image to Cloudinary for Hosting

Add another HTTP Request node to upload the downloaded image to Cloudinary using multipart/form-data POST request. Include the upload_preset parameter configured in your Cloudinary dashboard and attach the binary file data from the Telegram node.

Cloudinary responds with a secure URL used for video generation.

Step 6 — Generate AI Video From Image Prompt Using Piapi

Use an HTTP Request node to call Piapi’s API to create a short 5-second video from the image URL plus prompt text. Set the body as JSON with parameters for model, prompt, duration, and camera control as shown in the workflow.

This node triggers video creation asynchronously.

Step 7 — Wait for Video Processing Completion

Use a Wait node set to 2 minutes to allow Piapi to finish rendering the video.

After wait, make another HTTP Request to fetch the finished video URL from Piapi using the task ID received earlier.

Step 8 — For Text Prompt Inputs, Generate Video Using Blotato API

On the text branch, add an HTTP Request node to call Blotato’s video creation API. Pass the prompt as script, along with style and template ID in JSON body.

Wait for 2 minutes with another Wait node, then retrieve the completed video URL with a follow-up request.

Step 9 — Merge Video URL and Start Music Generation with Piapi

Use a Set node to harmonize the video URL output regardless of path (image or text) into one format. Then trigger Piapi’s audio generation API with the chosen music style prompt.

Step 10 — Wait for Music Generation and Retrieve Audio URL

Use a Wait node for 2 minutes, then an HTTP request to get the audio URL from Piapi output data.

Step 11 — Generate Short Script for Video Text Overlay Using GPT-4

Use the OpenAI (GPT-4o-mini) node to craft two lines of overlay text for the video based on the caption idea. Prompt the AI with specific instructions to create a hook and emotional payoff text.

Example prompt snippet:

You are a copywriter for short-form vertical videos.
Video topic:
{{ captionIdea }}
Write two short lines of overlay text:
text1: Hook (no period)
text2: Emotional or curiosity payoff (ends with ...)
Max 50 characters per line.

Step 12 — Parse AI Overlay Text with Code Node

Add a Code node to separate GPT-4 output into two fields. This makes subsequent video text element API calls easier to populate.

Step 13 — Merge Video and Music Into Final Video Asset

Make a HTTP Request call to JSON2Video API to combine video footage, overlay text, and the music audio track into a high-quality Instagram Story format video.

Step 14 — Wait for Fusion Completion and Get Final Video URL

Use Wait and HTTP request nodes to poll for final processing and retrieve the hosted video URL.

Step 15 — Generate Social Media Caption and SEO Title Using GPT-4

Trigger two separate OpenAI nodes one after another:

  • A short, compelling social caption based on the caption idea, focusing on actionable problem/solution language.
  • A punchy, curiosity-driven YouTube SEO-friendly video title.

Step 16 — Save Video Metadata to Google Sheets and Notify via Telegram

Append video URL, title, and social caption into a Google Sheet for content tracking.

Send both the final video and caption as a message to the original Telegram chat for confirmation or reuse.

Step 17 — Assign Platform IDs and Upload Video to Blotato for Multi-Social Distribution

Create a Set node containing the API platform IDs for 9 networks (Instagram, YouTube, TikTok, Facebook, Threads, Twitter, LinkedIn, Bluesky, Pinterest).

Use a final series of HTTP Request nodes to post the video and caption across all platforms through Blotato’s posts API.

5. Customizations ✏️

  • Adjust Video Style or Template: In the “Generate Video with blotato” HTTP Request node, change the JSON body “style” parameter or “template.id” to customize the video look.
  • Modify Caption Tone: Edit the prompt inside the “Generate Social Caption (GPT-4)” node to tailor captions—for example, make them more formal, humorous, or sales-focused.
  • Add Additional Social Platforms: Extend the “Assign Platform IDs for Blotato” Set node with new platform IDs and add corresponding HTTP request nodes for posting to new networks supported by Blotato API.
  • Use Different AI Models: Replace GPT-4o-mini with a different OpenAI model if preferred to fit budget or style.
  • Customize Video Duration: Edit the “duration” parameter in Piapi video generation HTTP requests to change how long the generated videos are.

6. Troubleshooting 🔧

Problem: Blotato API Key Errors

Cause: Invalid or expired API key for Blotato, resulting in 401 Unauthorized.

Solution: Verify your key in Blotato dashboard. Update the “blotato-api-key” header parameter in all HTTP Request nodes handling Blotato calls.

Problem: Telegram Trigger Doesn’t Fire

Cause: Incorrect bot token, missing webhook setup, or blocked updates from Telegram.

Solution: Recheck Telegram Bot token in credentials. Ensure webhook URL is correct and publicly accessible. Test with Telegram API tooling.

Problem: OpenAI Node Returns No Text

Cause: Prompt formatting issue or API limit exceeded.

Solution: Simplify or correct prompt text. Check API quotas and keys. Test OpenAI calls independently.

7. Pre-Production Checklist ✅

  • Confirm Telegram bot is properly set to receive and send messages.
  • Validate Blotato and Piapi API keys by calling their test endpoints.
  • Test Google Sheets connectivity by appending a dummy row.
  • Run manual test with a Telegram prompt containing both text and an image to verify branch logic.
  • Check that OAuth tokens for Google Sheets and OpenAI are current and authorized.
  • Ensure correct JSON structure in all HTTP requests to external APIs.

8. Deployment Guide

Activate your workflow in n8n by toggling the active switch on top. Ensure your webhook URLs remain accessible publicly if using Telegram triggers.

Monitor execution logs for errors. Use n8n’s credentials management for secure API key storage.

Schedule or trigger with Telegram messages as your publishing workflow. Use Google Sheets reports to track content output.

10. Conclusion

By building this workflow, you have transformed manual, time-consuming video content creation and cross-posting into one smooth, AI-powered automation. You can create custom AI-generated videos with personalized music and caption overlays from simple Telegram prompts or images. These videos publish automatically to 9 major social platforms, freeing up hours daily and reducing human errors.

Next, consider expanding with analytics collection from social platforms or enhancing captions with sentiment analysis AI to target audiences better. Or, add YouTube closed captions and scheduling automation for hyper-efficient digital marketing.

With this setup, your social media content strategy is scalable, creative, and near effortless.

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free