> ## 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.

# Conditional rules and variables

> How to branch the flow with rules, comparators, and variables

**Conditional rules** decide the flow's path: they compare a value (an answer or a variable) and, if the condition holds, route to the next node or to an action.

<img src="https://mintcdn.com/omniloy/Q9jZm4-SeFtgd8-M/images/olivia/conditional-rule.png?fit=max&auto=format&n=Q9jZm4-SeFtgd8-M&q=85&s=5e8531942c3769f4dffa624a9a8160a0" alt="Conditional rule editor" width="1687" height="1080" data-path="images/olivia/conditional-rule.png" />

## Comparators by type

Not every comparator applies to every type. The `always` comparator is the default branch and applies to any type.

| Type            | Comparators                                                                                         |
| --------------- | --------------------------------------------------------------------------------------------------- |
| Text            | `equals`, `not_equals`, `contains`, `starts_with`, `ends_with`, `any_of`                            |
| Numeric         | `equals`, `not_equals`, `greater_than`, `less_than`, `greater_or_equal`, `less_or_equal`, `between` |
| Date            | `equals`, `not_equals`, `before`, `after`, `between`                                                |
| Boolean         | `equals`, `not_equals`                                                                              |
| Multiple choice | `equals`, `not_equals`, `any_of`                                                                    |

`between` takes a pair of values (two numbers or two dates); `any_of` takes a list.

## Literal value or variable

The right-hand side of a rule can be a **literal value** or **another variable** (variable-to-variable comparison). Both sides must resolve to the same type. Variable comparison is allowed for: `equals`, `not_equals`, `contains`, `starts_with`, `ends_with`, and the ordering comparators (`greater_than`, `less_than`, `before`, `after`, etc.); not for `between`, `any_of`, or `always`. Multiple choice cannot be compared against a variable.

## Variables

**Built-in variables:**

| Variable                                              | Type                                     |
| ----------------------------------------------------- | ---------------------------------------- |
| `patient.first_name`, `patient.last_name`             | text                                     |
| `protocol.title`, `protocol.description`              | text                                     |
| `run.sequence_number`, `run.previous_score`           | number                                   |
| `date.today`, `date.next_call`                        | date                                     |
| `date.now_hour`                                       | number (0–23, in the session's timezone) |
| `question.<key>.answer`                               | depends on the question                  |
| `webhook.<key>.success` / `.http_status` / `.result…` | boolean / number / webhook data          |

**Custom variables:** declared per version (lowercase name, type text/number/date/boolean, required or not, with an optional default) and referenced as `custom.<name>` or `{{ name }}` in templates. Their values come from the enrollment or the run.

## Where rules can live

* On a **question** or a **webhook**, a rule may only read that node's own value.
* Any condition that crosses items (another question, a variable, another webhook, or variable-to-variable comparison) must live on a [decision node](/olivia/en/decisiones).
* A **flow phrase** allows at most one rule, and it must be `always`.
