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

# Conditional branching

> Route respondents to different paths based on their answers using condition rules, rule groups, and AND/OR operators.

Conditional branching lets you show different questions to different respondents based on what they've answered. You configure conditions on **edges** in the workflow canvas — the engine evaluates each outgoing edge in priority order and follows the first one that matches.

***

## How edge evaluation works

When a respondent submits an answer and the engine needs to advance:

1. All outgoing edges from the current node are sorted by **priority** (lowest number first).
2. Each edge is checked in order. An edge **matches** if all its condition groups pass.
3. The respondent is sent to the target of the **first matching edge**.
4. If no conditional edge matches, the **default route** (unconditional edge) is taken.
5. If there is no default route either, the respondent is sent to the **fallback end node**.

```
Node Q1
 ├── P0: If score ≥ 8  → Thank You (promoter)
 ├── P1: If score ≤ 6  → Detractor follow-up
 └── Default           → Neutral follow-up
```

<Note>
  Priority is displayed as **P0**, **P1**, **P2** … in the right panel. Lower
  numbers are evaluated first. You can reorder edges by dragging them.
</Note>

***

## Default route

Every node should have a **default route** — an unconditional edge that catches respondents who didn't match any conditional edge. There can only be one default route per node.

If all your edges are conditional and none matches, the respondent is sent to the fallback end node instead. That is usually not the intended behaviour, so always add a default route unless you deliberately want unmatched respondents to exit at the fallback.

***

## Adding a conditional edge

1. In the workflow canvas, draw an edge from a source node to a target node.
2. Click the edge to open it in the right panel.
3. Click **Add condition group**.
4. Add one or more rules within the group.
5. Set the group operator (`AND` — all rules must pass; `OR` — any rule must pass).
6. Add more groups if needed and set the **groups operator** (`AND` or `OR`).

***

## Condition structure

Each edge condition is a **GroupedEdgeCondition** with two levels:

```
GroupedEdgeCondition
 └── groups_operator: AND | OR
     └── groups[]
          ├── operator: AND | OR
          └── rules[]
               ├── question_node_id
               ├── operator  (equals, contains, greater_than, …)
               └── value
```

**Rule** — tests one question's answer against a value using an operator.

**Rule group** — combines multiple rules with an `AND` or `OR` operator.

**Groups operator** — combines multiple groups with `AND` or `OR`.

***

## Operators

Available operators depend on the question type being tested.

### Text questions (Short text, Long text, Email, Phone)

| Operator       | Passes when                                                 |
| -------------- | ----------------------------------------------------------- |
| `equals`       | Answer is exactly the value                                 |
| `not_equals`   | Answer is not the value                                     |
| `contains`     | Answer contains the value as a substring                    |
| `not_contains` | Answer does not contain the value                           |
| `is_answered`  | A non-empty answer was provided                             |
| `is_skipped`   | The question was skipped (optional question with no answer) |

### Number questions (Number, Date)

| Operator       | Passes when                              |
| -------------- | ---------------------------------------- |
| `equals`       | Answer equals the value                  |
| `not_equals`   | Answer does not equal the value          |
| `greater_than` | Answer > value                           |
| `gte`          | Answer ≥ value                           |
| `less_than`    | Answer \< value                          |
| `lte`          | Answer ≤ value                           |
| `between`      | Answer is between two values (inclusive) |
| `is_answered`  | A value was provided                     |
| `is_skipped`   | The question was skipped                 |

### Rating questions (Star rating, Number scale, Opinion scale)

Same operators as Number questions.

### Single-choice questions (Multiple choice, Dropdown, Yes/No)

| Operator      | Passes when                            |
| ------------- | -------------------------------------- |
| `equals`      | Selected option value equals the value |
| `not_equals`  | Selected option is not the value       |
| `is_answered` | An option was selected                 |
| `is_skipped`  | No option was selected                 |

### Multi-choice questions (Checkbox, Picture choice with multiple)

| Operator      | Passes when                                                      |
| ------------- | ---------------------------------------------------------------- |
| `in`          | Answer includes the value (value is one of the selected options) |
| `not_in`      | Answer does not include the value                                |
| `is_answered` | At least one option was selected                                 |
| `is_skipped`  | No options were selected                                         |

### Ranking

| Operator      | Passes when                                 |
| ------------- | ------------------------------------------- |
| `equals`      | Ranked list exactly matches the value array |
| `is_answered` | A ranking was provided                      |
| `is_skipped`  | No ranking was provided                     |

***

## Example: NPS routing

An NPS question (Opinion scale 0–10) routes respondents into three paths:

```
Q: How likely are you to recommend us? (0–10)
 ├── P0: score ≥ 9            → Promoter path
 ├── P1: score ≤ 6            → Detractor path
 └── Default                  → Passive path (7–8)
```

**Edge P0 config:**

* Group 1 → Rule: `nps_question` `gte` `9`

**Edge P1 config:**

* Group 1 → Rule: `nps_question` `lte` `6`

**Default edge:** no conditions.

***

## Example: Multi-condition routing

Route respondents who chose "Pricing" OR "Support" to a follow-up, everyone else to a general thank you:

```
Q: What brought you here? (Multiple choice)
 ├── P0: If answer in [pricing] OR answer in [support] → Follow-up
 └── Default → General thank you
```

**Edge P0 config:**

* Group operator: `OR`
* Group 1 → Rule: `reason_question` `in` `pricing`
* Group 2 → Rule: `reason_question` `in` `support`

***

## Next steps

<CardGroup cols={2}>
  <Card title="Scoring" icon="trophy" href="/building-forms/workflow/scoring">
    Assign point values to answers and use the score in routing conditions.
  </Card>

  <Card title="Workflow canvas" icon="diagram-project" href="/building-forms/workflow/canvas">
    Draw edges and manage priorities on the visual canvas.
  </Card>
</CardGroup>
