If you’re working in AI content creation, you know how tedious it can be to generate high-quality cinematic visuals on demand. That’s why I built an automated AI video generation workflow using n8n, OpenAI, Hugging Face, and RunwayML. Here’s a full breakdown of how it works—and how you can replicate or expand on it.

🌟 Objective
To build an automated Telegram-based video generation system that:
- Accepts user messages via Telegram.
- Converts them into cinematic video prompts using OpenAI (GPT-4o-mini).
- Generates an image using Hugging Face’s FLUX.1-schnell model.
- Uses Runway Gen-3 to convert the image and prompt into a realistic video.
- Sends the video back to the user—all within 1 minute.
⚙️ Tools Used
- n8n (Workflow Automation)
- OpenAI GPT-4o-mini (Prompt generation)
- Hugging Face Inference API (
FLUX.1-schnellmodel for images) - Runway ML API (
gen3a_turbofor video) - Telegram Bot (as input/output interface)
🔄 Workflow Breakdown
Step 1: Trigger via Telegram
- The user sends a text prompt via Telegram.
Telegram Triggernode captures the message.
Step 2: Generate Cinematic Prompt using GPT
- A LangChain OpenAI node (
gpt-4o-mini) processes the user’s text. - It outputs a video generation prompt focused on:
- Setting & environment
- Character motion
- Mood/emotion
- Camera styles (e.g., tracking, zoom)
- Lighting & time of day
Step 3: Generate Image from Prompt (Hugging Face)
- The cinematic setting is sent to Hugging Face’s FLUX.1 model.
- It returns a stylized cinematic image (PNG).
Step 4: Extract & Prepare Image
- An
Extract from Filenode processes the image to a base64 format. - This image is now ready to be passed into RunwayML.
Step 5: Send Image & Prompt to Runway ML
- A
POSTrequest sends the image and cinematic prompt to Runway’sgen3a_turboendpoint. - Settings include:
- Duration: 10 seconds
- Resolution ratio:
1280:768 - Watermark: Disabled
Step 6: Wait & Fetch Video Result
- A
Waitnode pauses for 60 seconds (to allow video generation). - Then a second API request fetches the video result using the Task ID.
Step 7: Deliver Video to Telegram
- The completed video is automatically sent back to the user via Telegram.
🔐 Security Reminder
Make sure to:
- NEVER hardcode API keys in public workflows.
- Always use environment variables or credential managers in production.
📝 Final Thoughts
This workflow is highly extensible. You can:
- Swap Hugging Face with MidJourney or Stability AI.
- Replace Telegram with Discord, Slack, or a web form.
- Add monetization (e.g., Stripe integration for premium requests).
- Generate country-specific cinematic warriors using another AI prompt pattern.
💡 Bonus: AI Warrior Prompt Extension
I added another node that transforms a country name into a cinematic third-person AI warrior prompt in “Majestic Walk” format. Great for Runway, Midjourney, or FLUX!
Sample Output for Japan:
“Front-facing slow-motion walk of a Japanese samurai with the head of a crimson dragon, dominating the frame with hyper-detailed lacquered armor and a gleaming katana…”
🚀 Wrap-Up
If you’re building your own creative AI pipeline—this is your springboard. From storytelling to branding to cinematic content generation, this end-to-end AI workflow offers automation, speed, and visual brilliance.
AIWorkflow #n8n #OpenAI #RunwayML #HuggingFace #AIVideo #Automation #NoCode #AIPrompting #CreativeAI
FULL CODE FOR WORKFLOW
{
"name": "ML RUN way and Hugging face",
"nodes": [
{
"parameters": {
"modelId": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "GPT-4O-MINI"
},
"messages": {
"values": [
{
"content": "=Instruction: Convert the following customer message into a highly realistic, cinematic 4K video generation prompt. Focus on visual detail, environment, character movement, mood, and camera angles. Make it suitable for AI video models like Runway or Gen-3.\n\nCustomer Message: \"{{ $json.message.text }}\"\n\nVideo Generation Prompt Output:\nDescribe a 4K, ultra-realistic scene based on the message above. Include:\n\nSetting & environment\n\nCharacters or objects\n\nMotion / action\n\nMood or emotion\n\nCamera style (e.g., tracking shot, slow zoom, drone view)\n\nLighting and time of day\n\nFilm-quality description"
}
]
},
"jsonOutput": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [-80, 460],
"id": "19546d26-a1d3-4f42-b590-deb1178aac97",
"name": "OpenAI2",
"credentials": {
"openAiApi": {
"id": "REPLACED_TEXT",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://router.huggingface.co/hf-inference/models/black-forest-labs/FLUX.1-schnell",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer REPLACED_TEXT"
},
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Accept",
"value": "image/png"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"inputs\":\"{{ $json.message.content.video_generation_prompt.setting_and_environment.description }}\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [280, 460],
"id": "b216ee7f-f2e1-4a0a-bc74-21d4a7807f59",
"name": "HTTP Request3"
},
{
"parameters": {
"updates": ["message"],
"additionalFields": {}
},
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.2,
"position": [-300, 460],
"id": "a6b522c2-a9dd-4f70-81f0-ddd507ba68e0",
"name": "Telegram Trigger",
"webhookId": "4b456cef-8d2a-4173-ac38-96aa7cdbeb1e",
"credentials": {
"telegramApi": {
"id": "REPLACED_TEXT",
"name": "Telegram account"
}
}
},
{
"parameters": {
"operation": "binaryToPropery",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [500, 460],
"id": "4291be57-c4ca-4640-ac2a-cdaac4f4734f",
"name": "Extract from File1"
},
{
"parameters": {
"method": "POST",
"url": "https://api.dev.runwayml.com/v1/image_to_video",
"authentication": "genericCredentialType",
"genericAuthType": "httpCustomAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"promptImage\": \"data:image/jpeg;base64,{{ $json.data }}\",\n \"model\": \"gen3a_turbo\", \n \"promptText\": \"{{ $('OpenAI2').item.json.message.content.prompt }}\",\n \"duration\": 10,\n \"ratio\": \"1280:768\", \n \"watermark\": false\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [720, 460],
"id": "80df4966-53f0-4e12-bb7c-38dfe7ef5b30",
"name": "HTTP Request4",
"credentials": {
"httpCustomAuth": {
"id": "REPLACED_TEXT",
"name": "RUNWAY ML"
}
}
},
{
"parameters": {
"amount": 60
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [900, 460],
"id": "14bd502a-0139-46c8-87df-5db1247692e7",
"name": "Wait1"
},
{
"parameters": {
"url": "=https://api.dev.runwayml.com/v1/tasks/{{ $json.id }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer REPLACED_TEXT"
},
{
"name": "X-Runway-Version",
"value": "2024-11-06"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1120, 460],
"id": "363242ed-9e9e-4a27-a58c-52c8633127b7",
"name": "HTTP Request5"
},
{
"parameters": {
"operation": "sendVideo",
"chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
"file": "={{ $json.output[0] }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [1340, 460],
"id": "46e18ffe-dd1c-4e27-bb39-bc467fa3d90a",
"name": "Telegram1",
"webhookId": "14fba241-3909-4711-860f-c9a955934b44",
"credentials": {
"telegramApi": {
"id": "REPLACED_TEXT",
"name": "Telegram account"
}
}
},
{
"parameters": {
"content": "THIS MODEL HAS COUNTRY PROMPT",
"color": 5
},
"type": "n8n-nodes-base.stickyNote",
"position": [-80, 260],
"typeVersion": 1,
"id": "c4f6f1ae-9288-4e95-b5ac-92e7bcd6efd3",
"name": "Sticky Note"
},
{
"parameters": {
"content": "FINALLY THIS HUGGING FACE API WORKS",
"color": 5
},
"type": "n8n-nodes-base.stickyNote",
"position": [240, 260],
"typeVersion": 1,
"id": "4367e356-b073-4256-9c24-32e56e8ba8bf",
"name": "Sticky Note1"
},
{
"parameters": {
"modelId": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "GPT-4O-MINI"
},
"messages": {
"values": [
{
"content": "=Third-Person Cinematic Prompt Generator — Majestic Walk Format\n\nTask:\nYou are an advanced AI that transforms a single country name into a cinematic prompt for image or video generation. [...] \n\nInput: United States\n{ \n \"prompt\": \"Front-facing slow-motion walk of a post-apocalyptic American warrior with the head of a bald eagle, dominating the frame with scavenged riot gear and a plasma rifle crackling with energy. [...]\" \n}"
}
]
},
"jsonOutput": true,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [620, 200],
"id": "60488de7-2778-4ec9-88bd-2e073f1644fd",
"name": "OpenAI",
"credentials": {
"openAiApi": {
"id": "REPLACED_TEXT",
"name": "OpenAi account"
}
}
}
],
"pinData": {},
"connections": {
"OpenAI2": {
"main": [[{ "node": "HTTP Request3", "type": "main", "index": 0 }]]
},
"HTTP Request3": {
"main": [[{ "node": "Extract from File1", "type": "main", "index": 0 }]]
},
"Telegram Trigger": {
"main": [[{ "node": "OpenAI2", "type": "main", "index": 0 }]]
},
"Extract from File1": {
"main": [[{ "node": "HTTP Request4", "type": "main", "index": 0 }]]
},
"HTTP Request4": {
"main": [[{ "node": "Wait1", "type": "main", "index": 0 }]]
},
"Wait1": {
"main": [[{ "node": "HTTP Request5", "type": "main", "index": 0 }]]
},
"HTTP Request5": {
"main": [[{ "node": "Telegram1", "type": "main", "index": 0 }]]
},
"Telegram1": {
"main": [[]]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "1fbae0cf-5ac5-4c3b-b586-8259fdbb62db",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "5459891812e7c4f47e0f9c614e88405f4156733b257e9461734291e116432123"
},
"id": "rW7w0qLcffeYgETU",
"tags": [
{
"createdAt": "2025-07-22T14:43:37.306Z",
"updatedAt": "2025-07-22T14:43:37.306Z",
"id": "RociHmxfByNRguIJ",
"name": "Sucess"
}
]
}

