Loop block
Learn how to run queries for each item in a data set during a workflow.
A Loop block contains an embedded block which runs for each evaluated item in an array. You use value
and index
to reference evaluated items and their indexes.
For example, you can automate a welcome email to new customers and customize the message for each recipient, using values like {{ value.email }}
and {{ value.name }}
.
Configure execution mode
Loop blocks support different modes for processing loop iterations:
- Parallel: Executes all iterations simultaneously.
- Sequential: Executes each iteration one at a time.
- Batch: Combines parallel and sequential modes to execute a parallel iterations in batches.
Within a Loop block, set the Execution mode to the mode you want to use.
The Sequential or Batch modes include an optional delay between iterations. This can help prevent API rate limits if the workflow needs loop through a large number of iterations.
Parallel
Parallel mode processes all iterations concurrently. For example, a Loop block that iterates through a list of users to update their information makes the same API request simultaneously.
Parallel loops complete more quickly than sequential or batched loops, resulting in shorter run times. Parallel loops are best for processing small amounts of data. Looping through large datasets can result in API limits or degraded service of your data source.
Sequential
Sequential mode processes each iteration sequentially. Each iteration must complete before the next one starts. For example, a Loop block that iterates through a list of users to update their information makes the same API request one at a time.
If you want to add a delay between sequential iterations, set Iteration delay (ms) to the desired amount of time.
Sequential loops take longer to process as each iteration must complete before the next one begins. This is especially useful if you're using APIs with strict rate limits or need to make the minimum amount of changes per iteration.
Batch
Batch mode runs a number of iterations in parallel, waiting for all to complete before moving to the next batch. Update Batch size to specify how many iterations should run per batch (default is 10
).
If you want to add a delay between batched iterations, set Batch delay (ms) to the desired amount of time.
For example, a Loop block that iterates through a list of users to update their information makes the same API request simultaneously.
Batched loops are a combination of parallel and sequential loops. You can find the right balance between concurrent iterations and the delay between each batch for speed and effectiveness.
Configure block settings
You can configure the following settings for Loop blocks.