Automations
For Each Loop Node
4 min readnode-foreach
Iterate over an array variable, running the connected child nodes once for each item.
For Each Loop Node
Loops over each element of an array variable, executing the downstream nodes for every item. The current item is available inside the loop via a named variable.
When to use it
- Process each chunk of a large scraped document through an AI node.
- Send a personalised message to each item in a list of contacts from a webhook response.
---
Required fields
| Field | Type | Required | Description |
|---|---|---|---|
| array | string | Yes | The array variable to iterate — e.g. {{variables.chunks}} |
| itemVar | string | Yes | Name for the current item variable inside the loop — e.g. chunk |
---
Optional fields
| Field | Type | Required | Description |
|---|---|---|---|
| limitItems | number | No | Maximum number of iterations (useful to cap AI costs) |
---
Variables available inside the loop
| Variable | Description |
|---|---|
{{variables.[itemVar]}} | Current array item for this iteration |
---
Step-by-step setup
- Ensure a previous node has set an array variable e.g.
{{variables.results}}(from Google Search, Webhook, etc.). - Add a For Each node.
- Set
arrayto{{variables.results}}. - Set
itemVartoresult(or any name you prefer). - Connect child nodes — they can reference
{{variables.result}}.
---
Example config
json
{
"array": "{{variables.searchResults}}",
"itemVar": "result",
"limitItems": 5
}
---
Tips & gotchas
- Without
limitItems, every item in the array will be processed — this can be expensive if the array is large and child nodes call AI APIs. - The For Each node creates a child branch in the canvas. Connect nodes below the loop body connector, not the main flow connector.
- After the loop completes, flow continues from the node connected to the loop's exit handle.