> For the complete documentation index, see [llms.txt](https://documentation.proto.cx/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.proto.cx/docs/modules/ai-agents/workflows-and-actions/branch.md).

# Branch

`Action` — Applies if/else logic to route the chat down different paths based on data already gathered. Maximum 10 conditions per Branch action.

## What it does

Evaluates conditions and directs the chat flow to a different path depending on what is true. Each branch can hold its own subsequent actions.

## When to use it

To route a conversation based on data already collected — a survey answer, an extracted field, or an API result — to decide what happens next.

## Settings

| Setting           | Description                                                                                                                     |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **If**            | The condition, entered as a [chat script](/docs/developers/chat-scripts.md) Python expression. Only Python syntax is supported. |
| **Add condition** | Adds a further else-if branch. Each can hold its own subsequent actions.                                                        |
| **Else**          | The path taken when no condition matches.                                                                                       |

Press **Save** to confirm edits.

## Using variables in conditions

[Chat variables](/docs/developers/chat-variables.md) can be used in branch conditions without curly brackets.

| Variable source     | Syntax                         |
| ------------------- | ------------------------------ |
| Ask survey (text)   | `variable.text`                |
| Ask survey (number) | `variable.norm.value`          |
| Set variable        | Use the variable name directly |

## Example

```
Branch
├─ If complaint_status.text == "resolved"
│  └─ Send message: "Good news – this has been resolved."
└─ Else
   └─ Live agent handoff
```

## Related

{% content-ref url="/pages/rTdnuIG08MgrRXkV3Alv" %}
[Set variable](/docs/modules/ai-agents/workflows-and-actions/set-variable.md)
{% endcontent-ref %}

{% content-ref url="/pages/AfNzbD8tzpbyRXhjL5zk" %}
[Jump](/docs/modules/ai-agents/workflows-and-actions/jump.md)
{% endcontent-ref %}

{% content-ref url="/pages/KpQiIGAmCVTGp5hdcACQ" %}
[Ask survey](/docs/modules/ai-agents/workflows-and-actions/ask-survey.md)
{% endcontent-ref %}
