> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oration.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Loop

> Repeat a section of the flow with a counter

The **Loop** node repeats a section of the flow a configurable number of times. It maintains a counter variable and provides three exit paths: continue looping, exit on condition, or exit when max iterations are reached.

## Behavior

* Increments the counter variable on each iteration
* Checks the exit condition (if configured) before each iteration
* Routes to `Loop` to continue, `Exit` when the exit condition is met, or `Max` when max iterations are reached

## Configuration

| Parameter         | Type    | Default        | Range | Description                                             |
| ----------------- | ------- | -------------- | ----- | ------------------------------------------------------- |
| `maxIterations`   | number  | `3`            | 1–100 | Maximum number of loop iterations                       |
| `counterVariable` | string  | `"loop_count"` | —     | Variable name that stores the current iteration number  |
| `exitCondition`   | string  | `""`           | —     | Expression that, when truthy, triggers the `Exit` path  |
| `continueOnError` | boolean | `false`        | —     | Continue looping even if a node in the loop body errors |

## Output handles

| Handle   | Description                                                                      |
| -------- | -------------------------------------------------------------------------------- |
| **Loop** | Continue to the next iteration — connect this to the first node in the loop body |
| **Exit** | Exit condition was met                                                           |
| **Max**  | Maximum iterations reached                                                       |

## Use cases

<AccordionGroup>
  <Accordion title="Retry pattern">
    Loop up to 3 times around an API Call node. On `API.SUCCESS`, take the `Exit` path. On `API.ERROR`, loop again. After 3 failures, the `Max` path plays an error message and ends the call.
  </Accordion>

  <Accordion title="Multi-item collection">
    Loop to collect multiple data points from the caller (e.g., "Enter item 1... Enter item 2..."). Use `{{loop_count}}` in the TTS text to indicate which item number.
  </Accordion>

  <Accordion title="Menu replay">
    Loop an IVR Menu so that callers who don't press a valid key hear the menu again, up to `maxIterations` times.
  </Accordion>
</AccordionGroup>
