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

# Decision nodes

> Route the flow based on rules, without speaking to the patient

A **decision node** is an internal node that **does not speak**: it asks no questions and says no phrases. Its only job is to route the flow by evaluating a set of [conditional rules](/olivia/en/reglas). It is where branching logic that spans several answers or variables lives.

<img src="https://mintcdn.com/omniloy/Q9jZm4-SeFtgd8-M/images/olivia/decision-node.png?fit=max&auto=format&n=Q9jZm4-SeFtgd8-M&q=85&s=faf4cd161e0823de1734a717d7f034fb" alt="Decision node" width="1687" height="1080" data-path="images/olivia/decision-node.png" />

## How rules are evaluated

* **First match wins**: rules are evaluated in order, and the first whose condition holds is taken.
* **Mandatory default branch**: the last rule must be `always`. This guarantees the node always has an exit; if it is missing, publishing the protocol fails.
* A decision node has no "own value", so every rule other than `always` must explicitly state which variable it evaluates.

```mermaid theme={null}
flowchart TD
  In[Enters the decision node] --> R1{Rule 1}
  R1 -->|matches| T1[Target 1]
  R1 -->|no| R2{Rule 2}
  R2 -->|matches| T2[Target 2]
  R2 -->|no| AF[always rule: default branch]
```

## Where a rule routes to

Each rule points to **one** of two things:

* **Another node** in the flow (a question, a phrase, a webhook, or another decision node), or
* **A terminal action** that closes the run:
  * `end_protocol_run` — finishes the questionnaire.
  * `mark_unresolved` — finishes it, marked as **unresolved**.

In the builder, terminal actions appear as distinct end nodes (End and Unresolved).

## When to use them

Use a decision node when branching depends on more than the immediate answer: combining several answers, comparing against a variable, or reacting to a webhook result.
