I want to discuss a task or project
Done! We will get back to you within one business day
Something went wrong. Please try again
Alexander Start:Duck 🦢
@olga_startduck
Write to Telegram
Назад
1k+ участников
Вступить в Telegram
n8n
22.10.2025

Telegram Sora AI Agent - System for generating and publishing video ads on TikTok

System description

N8n automation with an AI agent on Telegram that generates promotional game videos via Sora 2 based on uploaded photos of characters from games. Once the video is created, the system offers automatic posting on TikTok.

How it works:

  1. Send a character photo to (for example, from a game) on Telegram
  2. AI analyzes the image and creates a detailed scenario
  3. Sora 2 generates a 12-second ad video for a character
  4. The bot offers to post on TikTok
  5. If you agree, the video is automatically published

MAIN WORKFLOW

System components

Telegram Trigger

  • Feature: Monitoring incoming messages and files
  • Webhook ID: 6ffbdde8-db19-4657-b41c-8395dce7ac68
  • Processes: Photos, documents, text

AI Agent - Central Coordinator

  • Model: GPT-4.1-mini
  • Memory: Simple Memory with a link to chat.id
  • System prompt:
    • When received, file_id sends “Material in processing...”
    • Runs Gen_video with file_id
    • Offers a post on TikTok
    • Launches Auto_Posting if you agree

Agent tools:

send_text - Send messages to Telegram

  • Chat ID from the dialog context
  • Processing statuses and results

Gen_video - Generate video

  • Workflow ID: create workflow Gen_video separately and select from the list in this field
  • Input: image file_id
  • Output: WebContentLink video in Google Drive

Auto_Posting - Posting on TikTok

  • Workflow ID: Create workflow Auto_Posting separately and select from the list in this field
  • Input: WebContentLink video
  • Automated publishing

Simple Memory

  • Saves the history of conversations
  • Personalization for every user
  • Session Key: chat.id

SUB-WORKFLOW: GEN_VIDEO

Video generation process

1. When Executed by Another Workflow

Getting file_id from AI Agent from the main workflow

Input data:

json

{

“file_id”: “BqacagiaAxkbaambapgkeesdnvjqq_d7rlml8rcs_f0aamkhaai4kmblg9jxvdp4rlm2ba”

}

2. Download File

Downloading a character image from Telegram

  • Resource: file
  • File ID from the input
  • Output: Binary data images

3. Extract & Convert

Preparing an image for AI models

  • Conversion to base64
  • Preserving the original format
  • MIME Type: image/png or image/jpeg

4. Analyze Character

OpenAI Vision creates an ambassador profile

  • Model: chatgpt-4o-latest
  • Temperature: 0.7

Profile structure:

  • Primary identity (name, age, location, profession)
  • Appearance and style
  • Personality and communication
  • Way of life
  • The basis of trust

Result: 500+ words of character description

5. Build Video Prompts

Creating a master prompt for video

UGC video aesthetics:

  • Freehand camera shake
  • Natural focus switching
  • Real lighting
  • Cluttered background
  • Authentic imperfections

Frame-by-frame structure:

  • 0-2 sec: Mid-conversation clue
  • 2-9 seconds: Product demonstration
  • 9-12 sec: Natural completion

6. Generate Ad Script

Gemini 2.5 Pro creates a frame-by-frame scenario

  • A detailed description of every second
  • Camera position and motion
  • Character actions
  • Audio replicas

7. Clean Script

GPT-4.1 clears the script from technical comments

  • Model: gpt-4.1
  • Temperature: 0.3 (minimum creativity)

8. Generate First Frame

Adapting an image to a vertical format

  • Gemini Flash expands the background
  • Final size: 720x1280
  • Save the original composition

9. Sora 2 Video Generation

Main video generation:

json

{

“url”: "https://api.openai.com/v1/videos “,

“model”: “sora-2",

“seconds”: 12,

“size”: “720x1280",

“prompt”: “[cleared script]”,

“input_reference”: “[base64 first frame]”

}

10. Status Monitoring Loop

Readiness monitoring:

  • Wait 15 seconds
  • Status check
  • When completed, download
  • When processing, repeat the cycle
  • Maximum: 40 iterations (10 minutes)

11. Upload to Google Drive

Save the finished video:

  • Title: Video_ [timestamp] .mp4
  • Returning WebContentLink for publication

Output data:

json

{

“WebContentLink”: "https://drive.google.com/uc?id =... “,

“WebViewLink”: "https://drive.google.com/file/d/... “,

“duration”: 12,

“fileSize”: “15.2MB”

}

SUB-WORKFLOW: AUTO_POSTING

Publication process

1. When Executed by Another Workflow

Gets a video link from the main workflow

2. Set Accounts

Platform configuration:

json

{

“blotato_api_key”: “Blotato API key”,

“tiktok_id”: “TikTok account ID”,

“video_caption”: “Video description”,

“instagram_id”: “optional”,

“youtube_id”: “optional”,

“facebook_id”: “optional”

}

3. Upload to Blotato

Uploading videos to Blotato servers:

4. Publish to TikTok

Final publication:

json

{

“target”: {

“targetType”: “tiktok”,

“PrivacyLevel”: “PUBLIC_TO_EVERYONE”,

“DisabledDuet”: false,

“DisabledComments”: false

},

“content”: {

“text”: “Description and hashtags”,

“MediaURLS”: ["Video URL"]

},

“accountID”: “tiktok_id”

}

```

5. Send Confirmation

Telegram confirmation: “Video published”

Multiplatform support

By changing TargetType, you can publish to:

- Instagram Reels (TargetType: “instagram”)

- YouTube Shorts (TargetType: “youtube”)

- Facebook Reels (TargetType: “facebook”)

- Twitter/X (TargetType: “twitter”)

- LinkedIn (TargetType: “linkedin”)

- Pinterest (TargetType: “pinterest”)

---

USAGE SCENARIOS

Successful generation:

```

You are: [Send a photo]

Bot: “The material is being processed...”

[5-7 minutes of generation]

Bot: “The video is ready! Post to TikTok?”

You: 'Yes'

Bot: “Video posted”

```

Refusal to publish:

```

Bot: “The video is ready! Post to TikTok?”

You: 'No'

Bot: “Good! Video saved: [Google Drive link]”

METRICS AND EFFICIENCY

Time to complete the steps:

  • Image loading: 1-2 seconds
  • AI character analysis: 15-20 seconds
  • Scenario generation: 10-15 seconds
  • Frame preparation: 5-8 seconds
  • Sora 2 generation: 8-10 min
  • Loading to Drive: 3-5 sec
  • Publication: 5-10 sec

Common metrics:

  • Full time: 5-7 minutes
  • Success rate: 94%
  • Video price: $2-3
  • Platform support: 11+

SYSTEM SETUP

Required services:

  1. Telegram Bot
    • Create via @BotFather
    • Get a token
    • Configure in N8n
  2. OpenAI API
    • GPT-4.1-mini access key
    • Access to Sora 2
  3. Blotato Account
    • Register on blotato.com
    • Obtaining an API key
    • Connecting social media
  4. Google Drive
    • OAuth2 setup
    • Video folder

ERROR HANDLING

Error types and solutions:

  • 400: Wrong image format - check MIME type
  • 413: File is too big — 10MB limit
  • 429: Rate limit - wait 60 seconds and repeat
  • 500: Server error - retry after 30 seconds

Retry logic:

  • Maximum 3 attempts
  • Increasing the interval between attempts
  • Fallback to save to Drive without publishing

RESULT

The system turns Telegram into a full-fledged video studio, where you just need to send a photo to receive a ready-made promotional video posted on TikTok in a few minutes.

Читайте также

No items found.

write to us and we will show you the way to efficiency