AlekSystem Workflow Detail

Async Video Polling Engine - Background Job Handler for AI Video Generation Workflow Solution

๐Ÿ”„ Async Video Polling Engine - Background Job Handler for AI Video Generation

๐Ÿ”„ AI Video Polling Engine - Long-Running Job Handler for Veo, Sora & Seedance The async backbone that makes AI video generation production-ready โšก๐ŸŽฌ ๐ŸŽฅ See...

Rank 64 Verified workflow

Workflow overview

Why this workflow matters

Improves internal consulting operations and productivity. Relevant for managed services and support workflows.

๐Ÿ”„ AI Video Polling Engine - Long-Running Job Handler for Veo, Sora & Seedance The async backbone that makes AI video generation production-ready โšก๐ŸŽฌ ๐ŸŽฅ See It In Action ๐Ÿ”— Full Demo: youtu.be/OI_oJ_2F1O0 โš ๏ธ Must Read First This is a companion workflow for the main AI Shorts Generator: ๐Ÿ”— Main Workflow: AI Shorts Reactor This workflow handles the "waiting game" so your main bot stays fast and responsive. Think of it as the backstage crew that handles the heavy lifting while your main workflow performs on stage. ๐Ÿค” The Problem This Solves Without This Workflow: User sends message โ†“ Bot calls AI API โ†“ โณ Bot waits 2-5 minutes... (BLOCKED) โ†“ โŒ Timeout errors โŒ Execution limits exceeded โŒ Users think bot is broken โŒ Can't handle multiple requests With This Workflow: User sends message โ†“ Bot calls AI API โ†“ โœ… Bot responds instantly: "Video generating..." โ†“ ๐Ÿ”„ This webhook polls in background โ†“ โšก Main bot handles other users โ†“ โœ… Video ready โ†’ Auto-sends to user Result: Your bot feels instant, scales infinitely, and never times out ๐Ÿš€ ๐Ÿ” What This Workflow Does This is a dedicated polling webhook that acts as the async job handler for AI video generation. It's the invisible worker that: 1๏ธโƒฃ Receives the Job POST /webhook/poll-video { "sessionId": "user_123", "taskId": "veo_abc456", "model": "veo3", "attempt": 1 } 2๏ธโƒฃ Responds Instantly 200 OK - "Polling started" (Main workflow never waits!) 3๏ธโƒฃ Polls in Background Wait 60s โ†’ Check status โ†’ Repeat โฑ๏ธ Waits 1 minute between checks (API-friendly) ๐Ÿ”„ Polls up to 15 times (~15 minutes max) ๐ŸŽฏ Supports Veo, Sora, and Seedance APIs 4๏ธโƒฃ Detects Completion Handles multiple API response formats: // Veo format { status: "completed", videoUrl: "https://..." } // Market format (Sora/Seedance) { job: { status: "success", result: { url: "..." } } } // Legacy format { data: { video_url: "..." } } (No matter how the API responds, this workflow figures it out) 5๏ธโƒฃ Delivers the Video Once ready: ๐Ÿ“ฅ Downloads video from AI provider โ˜๏ธ Uploads to your S3 storage ๐Ÿ’พ Restores user session from Redis ๐Ÿ“ฑ Sends Telegram preview with buttons ๐Ÿ”„ Enables video extension (Veo only) ๐Ÿ“Š Logs metadata for analytics โš™๏ธ Technical Architecture The Flow: Main Workflow Polling Webhook โ”‚ โ”‚ โ”œโ”€โ”€[Trigger AI Job]โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ "Task ID: abc123" โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Return Instantly] โ”‚ โ”‚ "Generating..." โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Handle New User] โ”‚ โ”‚ โ”œโ”€โ”€[Wait 60s] โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Check Status] โ”‚ โ”‚ "Processing..." โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Wait 60s] โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Check Status] โ”‚ โ”‚ "Completed!" โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Download Video] โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€[Upload to S3] โ”‚ โ”‚ โ”‚ โ””โ”€โ”€[Send to User] โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ "Your video is ready!" ๐Ÿš€ Key Features โšก Non-Blocking Architecture Main workflow never waits Handle unlimited concurrent jobs Each user gets instant responses ๐Ÿ”„ Intelligent Polling Respects API rate limits (60s intervals) Auto-retries on transient failures Graceful timeout handling (15 attempts max) ๐ŸŽฏ Multi-Provider Support Handles different API formats: Veo** - record-info endpoint Sora** - Market job status Seedance** - Market job status ๐Ÿ›ก๏ธ Robust Error Handling โœ… Missing video URL โ†’ Retry with fallback parsers โœ… API timeout โ†’ Continue polling โœ… Invalid response โ†’ Parse alternative formats โœ… Max attempts reached โ†’ Notify user gracefully ๐Ÿ’พ Session Management Stores state in Redis Restores full context when video is ready Supports video extension workflows Maintains user preferences ๐Ÿ“Š Production Features Detailed logging at each step Metadata tracking (generation time, model used, etc.) S3 storage integration Telegram notifications Analytics-ready data structure ๐Ÿงฉ Integration Points Works Seamlessly With: | Use Case | How It Helps | |----------|--------------| | ๐Ÿค– Telegram Bots | Keeps bot responsive during 2-5 min video generation | | ๐Ÿ“บ YouTube Automation | Polls video, then triggers auto-publish | | ๐ŸŽฌ Multi-Video Pipelines | Handles 10+ videos simultaneously | | ๐Ÿข Content Agencies | Production-grade reliability for clients | | ๐Ÿงช A/B Testing | Generate multiple variations without blocking | Required Components: โœ… Main workflow that triggers video generation โœ… Redis for session storage โœ… S3-compatible storage for videos โœ… KIE.ai API credentials โœ… Telegram Bot (for notifications) ๐Ÿ“‹ How to Use Step 1: Set Up Main Workflow Import and configure the AI Shorts Reactor Step 2: Import This Webhook Add this workflow to your AlekSystem instance Step 3: Configure Credentials KIE.ai API key Redis connection S3 storage credentials Telegram bot token Step 4: Link Workflows In your main workflow, call this webhook: // After triggering AI video generation const response = await httpRequest({ method: 'POST', url: 'YOUR_WEBHOOK_URL/poll-video', body: { sessionId: sessionId, taskId: taskId, model: 'veo3', attempt: 1 } }); Step 5: Activate & Test Activate this polling webhook Trigger a video generation from main workflow Watch it poll in background and deliver results ๐ŸŽฏ Real-World Example Scenario: User generates 3 videos simultaneously Without This Workflow: User A: "Generate video" โ†’ Bot: โณ Processing... (BLOCKED 5 min) User B: "Generate video" โ†’ Bot: โŒ Timeout (main workflow still processing User A) User C: "Generate video" โ†’ Bot: โŒ Never receives request With This Workflow: User A: "Generate video" โ†’ Bot: โœ… "Generating! Check back in 3 min" โ†’ Polling webhook handles in background User B: "Generate video" โ†’ Bot: โœ… "Generating! Check back in 3 min" โ†’ Second polling instance starts User C: "Generate video" โ†’ Bot: โœ… "Generating! Check back in 3 min" โ†’ Third polling instance starts 3 minutes later--- User A: ๐Ÿ“น "Your video is ready!" [Preview] [Publish] User B: ๐Ÿ“น "Your video is ready!" [Preview] [Publish] User C: ๐Ÿ“น "Your video is ready!" [Preview] [Publish] All three users served simultaneously with zero blocking! ๐Ÿš€ ๐Ÿ”ง Customization Options Adjust Polling Frequency // Default: 60 seconds // For faster testing (use credits faster): const waitTime = 30; // seconds // For more API-friendly (slower updates): const waitTime = 90; // seconds Change Timeout Limits // Default: 15 attempts (15 minutes) const maxAttempts = 20; // Increase for longer videos Add More Providers Extend to support other AI video APIs: switch(model) { case 'veo3': // Existing Veo logic case 'runway': // Add Runway ML polling case 'pika': // Add Pika Labs polling } Custom Notifications Replace Telegram with: Discord webhooks Slack messages Email notifications SMS via Twilio Push notifications ๐Ÿ“Š Monitoring & Analytics What Gets Logged: { "sessionId": "user_123", "taskId": "veo_abc456", "model": "veo3", "status": "completed", "attempts": 7, "totalTime": "6m 32s", "videoUrl": "s3://bucket/videos/abc456.mp4", "metadata": { "duration": 5.2, "resolution": "1080x1920", "fileSize": "4.7MB" } } Track Key Metrics: โฑ๏ธ Average generation time per model ๐Ÿ”„ Polling attempts before completion โŒ Failure rate by provider ๐Ÿ’ฐ Cost per video (API usage) ๐Ÿ“ˆ Concurrent job capacity ๐Ÿšจ Troubleshooting "Video never completes" โœ… Check KIE.ai API status โœ… Verify task ID is valid โœ… Increase maxAttempts if needed โœ… Check API response format hasn't changed "Polling stops after 1 attempt" โœ… Ensure webhook URL is correct โœ… Check AlekSystem execution limits โœ… Verify Redis connection is stable "Video downloads but doesn't send" โœ… Check Telegram bot credentials โœ… Verify S3 upload succeeded โœ… Ensure Redis session exists โœ… Check Telegram chat ID is valid "Multiple videos get mixed up" โœ… Confirm sessionId is unique per user โœ… Check Redis key collisions โœ… Verify taskId is properly passed ๐Ÿ—๏ธ Architecture Benefits Why Separate This Logic? | Aspect | Monolithic Workflow | Separated Webhook | |--------|--------------------|--------------------| | โšก Response Time | 2-5 minutes | <1 second | | ๐Ÿ”„ Concurrency | 1 job at a time | Unlimited | | ๐Ÿ’ฐ Execution Costs | High (long-running) | Low (short bursts) | | ๐Ÿ› Debugging | Hard (mixed concerns) | Easy (isolated logic) | | ๐Ÿ“ˆ Scalability | Poor | Excellent | | ๐Ÿ”ง Maintenance | Complex | Simple | ๐Ÿ› ๏ธ Requirements Services Needed: โœ… AlekSystem Instance (cloud or self-hosted) โœ… KIE.ai API (Veo, Sora, Seedance access) โœ… Redis (session storage) โœ… S3-compatible Storage (videos) โœ… Telegram Bot (optional, for notifications) Skills Required: Basic AlekSystem knowledge Understanding of webhooks Redis basics (key-value storage) S3 upload concepts Setup Time: ~15 minutes Technical Level: Intermediate ๐Ÿท๏ธ Tags webhook polling async-jobs long-running-tasks ai-video veo sora seedance production-ready redis s3 telegram youtube-automation content-pipeline scalability microservices AlekSystem-webhook job-queue background-worker ๐Ÿ’ก Best Practices Do's โœ… Keep polling interval at 60s minimum (respect API limits) Always handle timeout scenarios Log generation metadata for analytics Use unique session IDs per user Clean up Redis after job completion Don'ts โŒ Don't poll faster than 30s (risk API bans) Don't store videos in Redis (use S3) Don't skip error handling Don't use this for real-time updates (<10s) Don't forget to activate the webhook ๐ŸŒŸ Success Stories After Implementing This Webhook: | Metric | Before | After | |--------|--------|-------| | โšก Bot response time | 2-5 min | <1 sec | | ๐ŸŽฌ Concurrent videos | 1 | 50+ | | โŒ Timeout errors | 30% | 0% | | ๐Ÿ˜Š User satisfaction | 6/10 | 9.5/10 | | ๐Ÿ’ฐ Execution costs | $50/mo | $12/mo | ๐Ÿ”— Related Workflows ๐ŸŽฌ Main: AI Shorts Reactor - The full video generation bot ๐Ÿ“ค YouTube Auto-Publisher - Publish completed videos ๐ŸŽจ Video Style Presets - Custom prompt templates ๐Ÿ“Š Analytics Dashboard - Track all generations ๐Ÿ“œ License MIT License - Free to use, modify, and distribute! โšก Make your AI video workflows production-ready. Let the webhook handle the waiting. โšก Created by Joe Venner | Built with โค๏ธ and AlekSystem | Part of the AI Shorts Reactor ecosystem

Best fit

Categories

AI/MLCommunicationMarketingProductivity

Services

RedisTelegramS3

Use cases

support automationcontent automationdocument intelligenceemail workflow automationoperations productivity