Hi everyone,
I built a reusable n8n workflow for a problem that appears with many AI video APIs: the initial request returns a task ID, while the generated video becomes available later.
A single HTTP Request node is not enough, and a naive polling loop can easily run forever, lose the task state, or hide failed generations. This workflow implements a bounded submit-and-poll pattern using standard n8n nodes.
What the workflow does
- Starts from a Manual Trigger and defines the model, prompt, video size, API base URL, polling interval, and maximum polling attempts.
- Sends a POST request to create a Seedance video generation task.
- Extracts and stores the returned
task_id. - Waits for the configured interval.
- Sends a GET request to retrieve the current task status.
- Carries the task ID and polling state through every iteration.
- Returns the final
result_urlwhen the task completes. - Stops with a clear error when the task fails or reaches the polling limit.
The workflow follows this structure:
manualTrigger
→ setFields
→ submitTask
→ saveTaskId
→ waitInterval
→ pollTask
→ mergeResults
→ mergeState
→ completed → outputResult
→ failed → failNode
→ timeout → timeoutFail
→ otherwise → continuePolling → waitInterval
Why the loop is bounded
The default configuration uses:
intervalSeconds = 5maxPolls = 120
This allows approximately 10 minutes for a generation to finish while guaranteeing that the workflow cannot poll forever.
You can adjust both values in setFields. The timeout branch checks:
poll_index >= maxPolls
A test with maxPolls = 3 confirms that the workflow sends exactly three GET requests and never sends a fourth request.
Authentication setup
Create an HTTP Header Auth credential in n8n:
Name: Authorization
Value: Bearer YOUR_VANCINE_API_KEY
Assign the same credential to both HTTP Request nodes:
submitTaskpollTask
The Code node only merges the API response with the carried loop state. It does not make network requests and does not contain an API key.
Using the workflow
- Download the workflow JSON from the GitHub repository.
- Import it into n8n.
- Create and assign the Header Auth credential.
- Update the prompt, model, size, polling interval, or maximum attempts if needed.
- Run the workflow manually.
- Read the generated video URL from
outputResult.
The repository also contains tested cURL, Node.js, Python, and Postman examples:
The workflow uses standard n8n nodes, contains no embedded credentials, and was import-tested with n8n 2.30.4.
For anyone who wants to test the Seedance API path, new Vancine accounts currently receive $1 in free credit and do not require a credit card:
Disclosure: I maintain Vancine, the API used in this example. I am sharing the workflow because the bounded polling and state-carrying pattern can also be adapted to other asynchronous APIs.
Would a webhook-triggered version that sends the completed video to cloud storage be useful?