---
title: "Branching by rules without cluttering the canvas"
description: "Router node (action_router): first_match and all_match, rules on request-context fields, default branch."
---

# Branching by rules without cluttering the canvas

The **Router** (`action_router`) sends the flow **down different branches** based on **rules** over **request-context fields** (channel, status, priority, subject, tags, and so on). Instead of many small check nodes, you define conditions in **one** place.

> **Limitation:** in the Node Inspector, **Field** is a closed list of context fields. You **cannot** enter an arbitrary scenario variable (`user_choice`, API response, etc.) into Router. To branch on a scenario constant, use Action **`switch`** — see [Built-in actions](/en/scenariobuilder/reference/standard-built-in-actions.md#2-routing-goto-alias-switch-clear-constant). For button menus — separate MessageKeyboard **edges**.

---

## How modes work

- **first_match** — the **first** matching rule wins; execution follows that branch.
- **all_match** — several rules may apply (see the UI and [router parameters](/en/scenariobuilder/reference/router-parameters.md)).

---

## Rules and the canvas

Rules in the inspector map to **outputs** on the node: each rule connects to its next node. You can add a **default** branch if nothing matches.

---

## Example uses

- Different paths by **channel** (Telegram, Widget, Email).
- Different logic by request **status** or **priority**.
- Branching by **subject** or **client / request tags**.
- «If channel A — path X, if B — path Y» without custom code.

---

## Add a router

1. Add **Router** from logic / templates.
2. Choose **mode** (first_match / all_match).
3. Add **rules** with conditions and branch ids.
4. Enable **default_branch** if needed.
5. Wire outputs on the canvas.

Field details: [Router parameters](/en/scenariobuilder/reference/router-parameters.md).

---

## See also

- [Parameter reference](/en/scenariobuilder/reference/router-parameters.md)
- [Built-in actions — switch](/en/scenariobuilder/reference/standard-built-in-actions.md)
- [What is the scenario editor](/en/scenariobuilder/explanation/what-is-scenario-editor.md)
- [Use action in scenario](/en/scenariobuilder/how-to/use-action-in-scenario.md)
