Await Component
Use the Await component to pause your main workflow until one or more background jobs, started by the Async Component, have finished. This allows you to retrieve results from asynchronous tasks and use them in your main flow.
Why this matters
What You’ll Configure
- Set Wait Conditions
- Provide Job IDs
- Handle the Results
- Best Practices
- Troubleshooting Tips
- What to Try Next
Step 1: Set Wait Conditions
Define the criteria for when the Await
component should stop waiting and allow the workflow to resume. The component proceeds as soon as either of these conditions is met.
Field | Required? | Description | Tips |
---|---|---|---|
Minimum Jobs Count | No | The number of async jobs that must be complete before continuing. | Default is 1 . Set this to the number of results you need to proceed. |
Maximum Wait Time | No | The maximum number of seconds to wait before resuming, even if jobs aren't done. | Default is 1 . Use this as a timeout to prevent your workflow from waiting forever. |
Race Condition
Step 2: Provide Job IDs
The Await
component needs to know which background jobs to monitor. You must provide the JobID
s from one or more Async
components.
Input | Required? | Description | Notes |
---|---|---|---|
Jobs | Yes | An array of JobID strings returned by the Async component. | You can pass a single JobID or a list of them. |
Passing Job IDs
Step 3: Handle the Results
Once the wait conditions are met, the Await
component outputs the results from all the completed jobs it was monitoring.
Output | Description | Data Structure |
---|---|---|
Results | An array containing the full output objects from each completed async job. | [{ "jobId": "...", "output": { ... } }, { ... }] |
// Example Results Output
[
{
"jobId": "job_12345",
"output": {
"status": "completed",
"processed_data": { "key": "value" }
}
},
{
"jobId": "job_67890",
"output": {
"status": "completed",
"processed_data": { "another_key": "another_value" }
}
}
]
Accessing Data
Best Practices
- Set a Realistic Timeout: Always configure the
Maximum Wait Time
to a reasonable value to prevent your workflow from getting stuck indefinitely. - Handle Partial Results: If your workflow might time out before all jobs are complete, add a Condition block after
Await
to check ifResults.length
matches the number of jobs you expected. - Use for User-Facing Workflows:
Await
is perfect for scenarios where a user is actively waiting for a result, such as data processing or report generation. - Combine with For Each: After awaiting multiple jobs, use a For Each Loop to process the
Results
array.
Troubleshooting Tips
If Await isn't working...
What to Try Next
- Use a Code Component after
Await
to parse theResults
array and transform it into a more usable format. - Feed the output from
Await
into a GenAI LLM Component to summarize the results from multiple background jobs. - Add a Condition block to check for empty
Results
and handle cases where no jobs were completed before the timeout.