I'll create a comprehensive n8n workflow for your YouTube automation system. This is an advanced workflow that combines multiple AI agents and services. Note that while I'm providing the core structure, you'll need additional API keys beyond just Telegram for the full functionality.
{
"name": "YouTube Content Automation Bot",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "telegram-trigger",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1,
"position": [250, 300],
"webhookId": "telegram-webhook",
"credentials": {
"telegramApi": {
"id": "1",
"name": "Telegram API"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"message\"][\"text\"]}}",
"operation": "contains",
"value2": "/start"
}
]
}
},
"id": "check-command",
"name": "Check Command",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [450, 300]
},
{
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{$json[\"message\"][\"chat\"][\"id\"]}}",
"text": "Welcome to YouTube Content Bot! 🎥\n\nChoose an option:\n1️⃣ /trending - Get trending topics\n2️⃣ /create_short - Create short video\n3️⃣ /create_long - Create long video\n4️⃣ /schedule - Set daily posting\n5️⃣ /status - Check bot status",
"replyMarkup": "inlineKeyboard",
"inlineKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "📈 Trending Topics",
"callbackData": "trending"
},
{
"text": "🎬 Create Short",
"callbackData": "short"
}
]
}
},
{
"row": {
"buttons": [
{
"text": "📹 Create Long",
"callbackData": "long"
},
{
"text": "⏰ Schedule",
"callbackData": "schedule"
}
]
}
}
]
}
},
"id": "send-welcome",
"name": "Send Welcome Message",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [650, 250],
"credentials": {
"telegramApi": {
"id": "1",
"name": "Telegram API"
}
}
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 9,
"minute": 0
}
]
}
},
"id": "daily-trigger",
"name": "Daily Reminder",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [250, 500]
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_OPENAI_API_KEY"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "gpt-4"
},
{
"name": "messages",
"value": "=[{\"role\": \"system\", \"content\": \"You are a YouTube trend analyst. Suggest 5 trending video topics for today that could reach millions of views. Include hashtags and brief descriptions.\"}, {\"role\": \"user\", \"content\": \"Give me trending topics for {{$json[\"niche\"] || \"general\"}} content\"}]"
}
]
},
"options": {}
},
"id": "trending-analysis",
"name": "Get Trending Topics",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [850, 300]
},
{
"parameters": {
"functionCode": "// Parse trending topics and format for Telegram\nconst response = JSON.parse($input.first().json.body);\nconst content = response.choices[0].message.content;\n\n// Extract topics\nconst topics = content.split('\\n').filter(line => line.trim());\n\nreturn {\n json: {\n topics: topics,\n formatted: `🔥 Today's Trending Topics:\\n\\n${topics.join('\\n\\n')}\\n\\nWhich topic would you like to create a video about?`,\n chatId: $node[\"telegram-trigger\"].json.message.chat.id\n }\n};"
},
"id": "format-topics",
"name": "Format Topics",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1050, 300]
},
{
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{$json[\"chatId\"]}}",
"text": "={{$json[\"formatted\"]}}",
"replyMarkup": "inlineKeyboard",
"inlineKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "Topic 1",
"callbackData": "select_topic_1"
},
{
"text": "Topic 2",
"callbackData": "select_topic_2"
}
]
}
},
{
"row": {
"buttons": [
{
"text": "Topic 3",
"callbackData": "select_topic_3"
},
{
"text": "Topic 4",
"callbackData": "select_topic_4"
}
]
}
}
]
}
},
"id": "send-topics",
"name": "Send Topics",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [1250, 300],
"credentials": {
"telegramApi": {
"id": "1",
"name": "Telegram API"
}
}
},
{
"parameters": {
"functionCode": "// Video Script Generator\nconst videoType = $input.first().json.videoType || 'short';\nconst topic = $input.first().json.selectedTopic;\nconst niche = $input.first().json.niche || 'general';\n\nconst scriptPrompt = {\n short: `Create a 60-second viral video script about: ${topic}. Include hook, main content, and call-to-action. Format for text-to-speech.`,\n long: `Create a 10-minute engaging video script about: ${topic}. Include introduction, 3-5 main points, examples, and conclusion. Format for text-to-speech.`\n};\n\nreturn {\n json: {\n prompt: scriptPrompt[videoType],\n videoType: videoType,\n topic: topic,\n niche: niche,\n duration: videoType === 'short' ? 60 : 600\n }\n};"
},
"id": "script-generator",
"name": "Generate Script",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [450, 700]
},
{
"parameters": {
"method": "POST",
"url": "https://api.elevenlabs.io/v1/text-to-speech/YOUR_VOICE_ID",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "xi-api-key",
"value": "YOUR_ELEVENLABS_API_KEY"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "text",
"value": "={{$json[\"script\"]}}"
},
{
"name": "model_id",
"value": "eleven_monolingual_v1"
},
{
"name": "voice_settings",
"value": "={\"stability\": 0.5, \"similarity_boost\": 0.5}"
}
]
},
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"id": "text-to-speech",
"name": "Generate Audio",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [650, 700]
},
{
"parameters": {
"functionCode": "// Image/Video Generation Prompt Creator\nconst videoType = $input.first().json.videoType;\nconst topic = $input.first().json.topic;\nconst niche = $input.first().json.niche;\n\nconst scenes = [];\n\nif (videoType === 'short') {\n // Generate 3-4 scenes for short video\n scenes.push(\n `Engaging thumbnail image for: ${topic}`,\n `Visual representation of main point about ${topic}`,\n `Call-to-action graphic for ${topic} video`\n );\n} else {\n // Generate 8-10 scenes for long video\n scenes.push(\n `Professional intro card for ${topic}`,\n `Chapter 1 visual for ${topic}`,\n `Chapter 2 visual for ${topic}`,\n `Chapter 3 visual for ${topic}`,\n `Conclusion slide for ${topic}`,\n `Subscribe reminder graphic`\n );\n}\n\nreturn {\n json: {\n scenes: scenes,\n style: niche === 'kids' ? 'colorful cartoon style, child-friendly' : 'professional, modern design',\n videoType: videoType\n }\n};"
},
"id": "scene-generator",
"name": "Generate Scene Prompts",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [850, 700]
},
{
"parameters": {
"resource": "file",
"operation": "upload",
"fileName": "={{$json[\"title\"]}}.mp4",
"binaryPropertyName": "data",
"additionalFields": {
"description": "={{$json[\"description\"]}}",
"tags": "={{$json[\"tags\"]}}",
"categoryId": "={{$json[\"category\"]}}",
"privacyStatus": "public"
}
},
"id": "youtube-upload",
"name": "Upload to YouTube",
"type": "n8n-nodes-base.youTube",
"typeVersion": 1,
"position": [1250, 700],
"credentials": {
"youTubeOAuth2Api": {
"id": "2",
"name": "YouTube OAuth2"
}
}
},
{
"parameters": {
"functionCode": "// Store user preferences and schedule\nconst userId = $input.first().json.userId;\nconst preferences = {\n userId: userId,\n videoType: $input.first().json.videoType || 'short',\n niche: $input.first().json.niche || 'general',\n postingTime: $input.first().json.postingTime || '09:00',\n autoApprove: $input.first().json.autoApprove || false,\n topics: $input.first().json.favoriteTopics || []\n};\n\nreturn {\n json: preferences\n};"
},
"id": "user-preferences",
"name": "Store Preferences",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1050, 500]
},
{
"parameters": {
"resource": "database",
"operation": "append",
"databaseId": "YOUR_NOTION_DATABASE_ID",
"properties": {
"values": {
"User ID": "={{$json[\"userId\"]}}",
"Preferences": "={{JSON.stringify($json)}}",
"Last Updated": "={{new Date().toISOString()}}"
}
}
},
"id": "store-data",
"name": "Store in Database",
"type": "n8n-nodes-base.notion",
"typeVersion": 1,
"position": [1250, 500],
"credentials": {
"notionApi": {
"id": "3",
"name": "Notion API"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"callback_query\"][\"data\"]}}",
"operation": "startsWith",
"value2": "select_topic"
}
]
}
},
"id": "check-callback",
"name": "Check Callback",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [450, 500]
},
{
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{$json[\"userId\"]}}",
"text": "📊 Daily YouTube Report:\\n\\n✅ Video posted successfully!\\n👁 Views: {{$json[\"views\"]}}\\n👍 Likes: {{$json[\"likes\"]}}\\n💬 Comments: {{$json[\"comments\"]}}\\n\\nNext video scheduled for tomorrow at {{$json[\"nextPostTime\"]}}"
},
"id": "send-report",
"name": "Send Daily Report",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [1450, 700],
"credentials": {
"telegramApi": {
"id": "1",
"name": "Telegram API"
}
}
}
],
"connections": {
"telegram-trigger": {
"main": [
[
{
"node": "check-command",
"type": "main",
"index": 0
}
]
]
},
"check-command": {
"main": [
[
{
"node": "send-welcome",
"type": "main",
"index": 0
}
],
[
{
"node": "check-callback",
"type": "main",
"index": 0
}
]
]
},
"daily-trigger": {
"main": [
[
{
"node": "trending-analysis",
"type": "main",
"index": 0
}
]
]
},
"trending-analysis": {
"main": [
[
{
"node": "format-topics",
"type": "main",
"index": 0
}
]
]
},
"format-topics": {
"main": [
[
{
"node": "send-topics",
"type": "main",
"index": 0
}
]
]
},
"check-callback": {
"main": [
[
{
"node": "script-generator",
"type": "main",
"index": 0
}
],
[
{
"node": "user-preferences",
"type": "main",
"index": 0
}
]
]
},
"script-generator": {
"main": [
[
{
"node": "text-to-speech",
"type": "main",
"index": 0
}
]
]
},
"text-to-speech": {
"main": [
[
{
"node": "scene-generator",
"type": "main",
"index": 0
}
]
]
},
"scene-generator": {
"main": [
[
{
"node": "youtube-upload",
"type": "main",
"index": 0
}
]
]
},
"youtube-upload": {
"main": [
[
{
"node": "send-report",
"type": "main",
"index": 0
}
]
]
},
"user-preferences": {
"main": [
[
{
"node": "store-data",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "1",
"id": "youtube-automation-bot",
"meta": {
"instanceId": "a47de6e63a88fce05377fdea3df6ba6a01fc01b8c88694396c9218b977691cd7"
},
"tags": []
}
Setup Instructions:
-
Required API Keys (beyond Telegram):
- OpenAI API key (for content generation)
- ElevenLabs API key (for text-to-speech)
- YouTube OAuth2 credentials
- Notion API key (optional, for data storage)
-
Additional Components Needed:
- For video generation: Consider integrating Runway ML, Stable Diffusion, or D-ID APIs
- For image generation: DALL-E, Midjourney, or Stable Diffusion APIs
- For video editing: FFmpeg node or external service like Shotstack
-
Telegram Bot Setup:
- Create bot via @BotFather
- Set webhook to your n8n instance
- Add bot commands: /start, /trending, /create_short, /create_long
-
Workflow Enhancements:
- Add error handling nodes
- Implement retry logic for API calls
- Add content moderation checks
- Set up analytics tracking
-
Video Assembly Pipeline (to add):
// Add this as a Code node after scene generation
const ffmpegCommand = `
ffmpeg -i audio.mp3 -loop 1 -i image_%d.png
-c:v libx264 -c:a aac -shortest output.mp4
`;
This workflow provides the foundation for your YouTube automation system. You'll need to customize it based on your specific needs and add the actual video generation services you prefer to use.