Skip to main content
Version: V11

Loop Node

The Loop Node executes workflow steps repeatedly over collections or fixed counts with optional early exit conditions. It supports array iteration, counting loops, scoped variables for current item and index, and break conditions for controlled iteration. The node has two output handles (Continue and Done) that route execution into the loop body and to downstream nodes after completion.

How It Works

The Loop node operates as a state machine with two modes: initialization and continuation. On first execution, it initializes loop variables including the current index (starting from Start Index), current item (if iterating over a collection), and internal loop state tracking maximum iterations and available items. It then signals "continue" to route execution into the loop body.

When execution returns from the loop body, the node enters continuation mode. It first evaluates break conditions (if configured) to determine if early exit is needed, then checks if more iterations remain by comparing the current index against the calculated end index. If continuing, the node increments the index, updates the current item to the next element, and signals "continue" again. When all iterations complete or break conditions are met, it signals "done" and cleans up loop variables by setting them to null, making them unavailable to downstream nodes outside the loop.

The node supports three iteration modes: collection iteration processes all items in an array, fixed count iteration executes a specific number of times without data, and limited collection iteration processes up to N items from a collection. The mode is determined by which parameters are configured (Input Field, Iterations, or both).

The node has two output handles: Continue and Done. The Continue handle routes execution into the loop body for each iteration. The Done handle routes execution to downstream nodes after the loop completes.

Configuration Parameters

Input Field

Input Field (Variable, Optional): Workflow variable containing a list or array of items to iterate over.

If not provided, the loop executes for the specified number of iterations as a counting loop. Supports any array type including strings, numbers, objects, or mixed types.

Start Index

Start Index (Number, Default: 0): Starting index for the loop using 0-based indexing.

When iterating over a collection, the loop begins from this position in the array. For counting loops, this sets the initial value of the Current Index Variable. Variable interpolation with ${variable_name} is supported.

Iterations

Iterations (Number, Optional): Number of iterations for the loop (range 1–10,000).

ConfigurationBehaviorUse for
Iterations OnlySimple counting loop executing N timesRetry logic, polling operations, repeating actions
Input Field OnlyProcesses all items in collectionProcessing every item in arrays, documents, search results
BothProcesses first N items from collectionTesting workflows, implementing pagination, limiting processing

Variable interpolation with ${variable_name} is supported.

Current Index Variable

Current Index Variable (Text, Optional): Scoped variable to store the current iteration index (0-based).

This variable is accessible within the loop body and downstream nodes, automatically incremented with each iteration.

Common naming patterns: loop_index, current_index, i, document_index

Current Item Variable

Current Item Variable (Text, Optional): Scoped variable to store the current item from the collection being iterated.

This variable is only populated when iterating over a collection (Input Field provided). For counting loops, it remains null.

Common naming patterns: current_item, item, document, record

Break Conditions

Break Conditions (Array, Optional): Conditions that cause the loop to exit early.

When conditions evaluate to true, the loop stops immediately. Break conditions are evaluated at the start of each iteration after the first, meaning the first iteration always executes before conditions are checked.

Each condition has the following properties:

Data Field (Text, Required): Variable to evaluate. Supports dot notation (e.g., result.status).

Data Type (Dropdown, Default: String): Type of field (String, Number, Boolean, Date, Array, Object).

Operator (Dropdown, Required): Comparison operator based on data type (same as IF Conditional node).

Value (Text, Conditional): Value to compare against. Supports variable interpolation with ${variable_name}.

Case Sensitive (Toggle, Default: OFF): Enables case-sensitive string comparisons.

Strict Type Validation (Toggle, Default: OFF): Prevents automatic type conversion.

Break Conditions Operator

Break Conditions Operator (Dropdown, Default: AND): How to combine multiple break conditions.

OperatorBehaviorUse for
AND (default)All conditions must be true to breakAll criteria must be met (e.g., found AND verified)
ORAt least one condition must be true to breakAny criterion triggers exit (e.g., error OR timeout)

Common Parameters

This node supports common parameters shared across workflow nodes. For detailed information, see Common Parameters.

Best Practices

  • Use descriptive variable names that reflect what is being iterated (e.g., document_index instead of i)
  • Configure break conditions for loops that might run indefinitely or when searching for specific results
  • Use Start Index to implement pagination or resume processing from a checkpoint
  • Keep loop bodies simple; extract complex logic into separate nodes for better maintainability
  • Monitor loop progress using Stream Output Response during development

Limitations

  • Maximum iterations: Limited to 10,000 iterations per loop execution to prevent infinite loops.
  • No nested loop variables: When nesting loops, each loop must use unique variable names to avoid conflicts.
  • Sequential execution only: Loop iterations execute sequentially, not in parallel.
  • Break conditions evaluated after first iteration: The first iteration always executes before conditions are checked.
  • Collection modification: Modifying the Input Field collection during loop execution may cause unexpected behavior.