> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/workflow-execution/branches-conditions-and-routing.md).

# Branches, Conditions, and Routing

Routing selects the processing path for an input. Use a condition when the rule is explicit. Use AI routing when a model must interpret the request to choose a category.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FvWbHcmDUdsf83I3tFunk%2FG024.mp4?alt=media&token=eef26ea6-5291-419c-8c8a-4a10329ef8b4>" %}

## Before you begin

An editable workflow and clearly defined destination branches.

## Key concepts

| Term       | Definition                                                                                                                                      |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| AI routing | A model-based choice among configured categories or destinations. Use distinct categories and review the selected route for ambiguous requests. |
| Branch     | One possible path after a routing decision. An unselected branch is not automatically a failed branch.                                          |

## Configuration options

| Option    | Purpose                                                                            | Behavior                                                                          |
| --------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| Condition | An explicit comparison or rule used to choose a path.                              | The compared value and its type must match the intended rule.                     |
| Fallback  | An alternate response, model, or branch used under a configured failure condition. | A fallback can produce a usable answer while the original operation still failed. |

## Configure a branch

1. Define the conditions or categories for each branch.
2. Map the value the router must inspect. Connect each destination to the appropriate branch.

![Choose the comparison operator and value for the condition.](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/3WSA943XEM6FCRqD2TOE/assets/g024-g024-02-condition.png)

Choose the comparison operator and value for the condition.

3. Run representative inputs and inspect the selected route and its downstream result.

Only the intended path supplies the result for that decision.

## Behavior and limitations

A condition and an AI classification have different failure modes. Check value types for explicit comparisons. Make AI categories distinct and define how unmatched requests should be handled. A branch that was not selected should not be treated as a failed node.

## Related resources

[Conditional and AI routing](/guides-and-quickstarts/workflow-builder/conditional-and-ai-routing.md)

[Execution Order and Node Dependencies](/technical-reference/workflow-execution/execution-order-and-node-dependencies.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/workflow-execution/branches-conditions-and-routing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
