π¬ π Async Video Polling Engine - Background Job Handler for AI Video Generation
β‘ 49 views Β· π¬ Content Creation & Video
π‘ Pro Tip β Since TikTok doesnβt have a public API, getting data usually means fragile HTTP scraping. ScraperNode is a community node that gives you clean JSON for TikTok profiles, videos, and comments β drop it into your workflow and skip the parsing.
Description
π 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-infoendpoint - 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 n8n 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 n8n 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:
- β n8n 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 n8n 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 n8n-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 n8n | Part of the AI Shorts Reactor ecosystem
π Nodes Used
HTTP Request, Redis, Webhook, Telegram, S3
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File
