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

# Condition step

> Branch the workflow based on data or AI judgment.

The Condition step splits the workflow into multiple branches. Execution routes down the first branch whose expression matches — or down the default branch if none match.

## How it works

The Condition step evaluates each branch's expression in order against the workflow context (`ctx`). The first expression that evaluates to true determines which branch executes next. If no expression matches, execution follows the **default condition** branch.

<Frame>
  <img src="https://mintcdn.com/anyreach/Y4eUcly6KbZurDWD/images/workflows/condition.png?fit=max&auto=format&n=Y4eUcly6KbZurDWD&q=85&s=5019cf125783ece272748ae993062cd3" alt="Condition step showing branches on canvas" width="3164" height="1656" data-path="images/workflows/condition.png" />
</Frame>

To add a new condition branch, hover over a condition node. A "+" icon will appear, click it to create an additional branch for your condition logic.

<Frame>
  <img src="https://mintcdn.com/anyreach/Y4eUcly6KbZurDWD/images/workflows/add-condition.png?fit=max&auto=format&n=Y4eUcly6KbZurDWD&q=85&s=d026ee55560477e8717ae9238b989a8f" alt="Condition step showing branches on canvas" width="2624" height="916" data-path="images/workflows/add-condition.png" />
</Frame>

## When to use it

| Use Condition when                                             | Don't use it when                                      |
| -------------------------------------------------------------- | ------------------------------------------------------ |
| Routing based on a data value (status code, field value, tier) | The logic is computational — use a Code step           |
| Classifying free-text with AI judgment                         | You already have structured data — use JSONata, not AI |
| Implementing a switch over an enum                             |                                                        |

## Inspector

Clicking on a condition branch in the workflow opens an editor in the inspector. Here, you can set a custom name for the branch and define its associated condition expression.

<Frame>
  <img src="https://mintcdn.com/anyreach/Y4eUcly6KbZurDWD/images/workflows/condition-editor.png?fit=max&auto=format&n=Y4eUcly6KbZurDWD&q=85&s=e6a338cee6e93639e3c2d5e1ee6ef814" alt="Condition step showing branches on canvas" width="2294" height="1170" data-path="images/workflows/condition-editor.png" />
</Frame>

## Expression Types

Each branch in a Condition step uses an expression to determine when that branch should be followed. There are two supported types:

**JSONata expressions** — These are evaluated at runtime against the current workflow context (`ctx`). Use JSONata when you want to perform checks on structured data.

Examples:

```
{{ n1.name = "Adam Zampa" }}
{{ n1.score > 50 }}
```

You can also use the AI-powered expression generator in the editor to help you craft the right condition.

**AI expressions** — These let you phrase your condition as a natural language question to the LLM (Large Language Model). The model returns a true or false answer, allowing for more flexible or fuzzy logic that can use free text fields.

Example:

```
${ does {{n1.name}} contain the word "Adam"? respond yes/no }
```

Use JSONata for strict, structured logic where possible. Use AI expressions for complex, human-like reasoning needs.

## Branch ordering

Conditions are evaluated top to bottom. **First match wins** — once a branch matches, the others are not evaluated.

Order from most specific to least specific:

```
Branch 1: {{ n2.status_code = 200 }}     ← most specific
Branch 2: {{ n3.status_code >= 400 }}    ← catches all errors
default:                               ← fallback
```

## Default branch

Every Condition step has a default branch that executes when no other branch matches. Always wire it to a meaningful step — leaving the default unconnected means the workflow silently stops if nothing matches.
