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
Services
Use cases
Need another direction?