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
FieldTypeRequiredDescription
arraystringYesThe array variable to iterate — e.g. {{variables.chunks}}
itemVarstringYesName for the current item variable inside the loop — e.g. chunk

---

Optional fields
FieldTypeRequiredDescription
limitItemsnumberNoMaximum number of iterations (useful to cap AI costs)

---

Variables available inside the loop
VariableDescription
{{variables.[itemVar]}}Current array item for this iteration

---

Step-by-step setup
  1. Ensure a previous node has set an array variable e.g. {{variables.results}} (from Google Search, Webhook, etc.).
  2. Add a For Each node.
  3. Set array to {{variables.results}}.
  4. Set itemVar to result (or any name you prefer).
  5. 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.