# Routing rules

Build reusable sets of conditions once, then use them across your routers to gate, branch and check deadlines.

Source: https://support.rework.com/article/prospect-rules

A routing rule is a saved set of conditions, for example "assigned agent is empty and the channel is our main Page". You write a rule once and reference it from as many routers as you like. So when the definition of "urgent" changes, it's one edit, not twelve. 🙌

## Create a rule

1. Go to **Routers**, pick the service, then open **Routing rules**.
   
2. Click **New rule** **(1)** and fill in **Rule name** **(2)**.
   
3. Under **Conditions**, build each row from a field, an operator and a value **(3)**. Use **Add condition** or **Add inner group** **(4)** for more rows, then click **Create rule** **(5)**.
   
   ![New rule dialog in the Sales service, with the New rule button (1), the Rule name box (2), the Where condition row with field, operator and value (3), the Add condition and Add inner group links (4) and the Create rule button (5) highlighted](https://storage.googleapis.com/reworkv3-public/success/260928/GJFOIAoRD4VPWVDbsxwsfN6Lm9Em4TK4L3qC8LQh75Tmr8epOWGPYmv1dLGPlk7r/img.0TDnxqAZpdXrsnw2wPu0navlOdsQgthPXzKUwHpA8rjKjuJWR3ZceRZSsckc1qBb.png)

Existing rules show a one-line preview of their conditions. Hover over a row for **Edit**, **Duplicate** and **Delete**. Click it to open a read-only side panel that also lists which routers use the rule. Rules marked **Preset** ship with the product and can't be edited.

Once you have more than five rules, a search box appears above the list to help you find them.

## What a rule can match on

Each condition is a field, an operator and a value. Open **Select field** **(1)** and the fields are grouped **(2)**, with a search box at the top.

![Select field dropdown (1) open in the New rule dialog, showing the System fields group (2) starting with Assigned agent, Followers, Status, Inbox state, Stage, Labels, Channel and Provider](https://storage.googleapis.com/reworkv3-public/success/260928/hFKPLWH6Q8FU6USD0hqIeoolvmK853SdUOR4vUPfpH2cFocGXcw1JkfIkVOUA4No/img.63hrB6m8leNJWukQ6uooCZR6Y9mczWcJwETesLWBKtFD2xmZ8qVPeA36E93HoScJ.png)

**System fields** are what the conversation already knows:

| Group | Fields |
| --- | --- |
| Ownership | **Assigned agent**, **Followers** |
| State | **Status**, **Inbox state**, **Stage**, **Labels** |
| Origin | **Channel**, **Provider**, **Source**, **Inbox** |
| Content and record | **Conversation name**, **Last message text**, **Record type**, **Profile id**, **Linked records** |
| AI | **AI replying**, **AI agent** |
| Timing | **Created**, **Last message**, **Last customer message**, **Assigned**, **First assigned**, **Closed**, **Snoozed until**, **Updated** |

**Status** offers **Open**, **Snoozed** and **Closed**. **Inbox state** offers **New**, **Unanswered** and **Waiting**. They're two different things, and you'll find both explained in [Conversation status](https://support.rework.com/article/prospect-conversation-status).

Below the system fields, the list also has **Contact fields** (**Phone**, **Email**, **Company**, **All phones**, **All emails**, **Prospect id**) and **Attribution fields** (such as **Source (incl. Organic)**, **Ad id (first touch)**, **Ad id (latest touch)**, **Meta ad id** and **Meta click ID**).

**Custom fields** are whatever your team has attached to this service. They appear under their own group in the field list.

The operators you're offered depend on the field's type:

- Text fields get **contains**, **starts with**, **ends with** and their negatives.
  
- Numbers get **greater than** and **less or equal**.
  
- Dates get **before**, **after**, **more than … ago**, **within the last …** and the two range operators.
  
- Lists get **is any of** and **is none of**.
  
- A person field such as **Assigned agent** **(1)** gets **equals**, **does not equal**, **is any of**, **is none of**, plus **is in team** and **is not in team** **(2)**.
  

**is empty** **(3)** and **is not empty** are available almost everywhere.

![Operator list for the Assigned agent field (1), with is in team and is not in team (2) and is empty (3) highlighted](https://storage.googleapis.com/reworkv3-public/success/260928/q66uQfw1Ur7953YVp7JYYGWsPf6rU93JTDK3cAGRsTxfMqOjBI98i09h1eUZHEEv/img.Q9Inn416ODhYwPYLjvTRo47im3FSGazp7VQAclVM9O4AqglQjxZJYRzhsjXDCcHC.png)

> **Tip:** For an unassigned conversation, **Assigned agent** **is empty** is the test you want.

## Conditions, groups and AND / OR

Conditions sit inside a group, and the group's join (**AND** or **OR**) is a toggle between the rows. Click it to switch the whole group.

For anything more involved, use **Add inner group**. A nested group has its own join, so you can express "channel is A **AND** (label is urgent **OR** stage is negotiation)". Groups nest up to three levels deep.

A rule with no conditions matches every conversation. The list flags that case for you rather than letting it pass silently.

## Where a rule is used

A rule doesn't do anything on its own. It takes effect when a router step points at it:

- An **Entry Rule** step uses it as a gate: conversations that don't pass stop there.
  
- A **Routing Rule** step uses it as a branch: matches go down one path, everything else down the other.
  
- A **Service Level Agreement** step can use it as the test for whether a deadline was met.
  

The side panel's **Used in** rows link straight to the router that references the rule.

## How order decides the outcome

Three separate orderings are at work here. Mixing them up is the usual cause of "the wrong thing happened", so it's worth a quick look.

**Routers run in list order.** When one event could start several routers, the position of the row in **SLA Flows** decides which is considered first. Drag to change it.

**Steps run top to bottom.** Inside a router, the walk starts at the trigger and follows the connections. A gate that drops a conversation ends that path, and nothing below it runs.

**Branches are first-match.** A **Routing Rule** sends matches one way and everything else the other, so chains of them behave like a series of "if … otherwise if …" tests. Put the most specific rule first, or a broader one above it will claim the conversation.

## Change a rule that is already live

Editing a rule doesn't change routers that are already published. Each published version carries its own copy of the conditions it used.

A rule whose live routers are behind shows a flag reading **N flows to republish**. Open it and republish from there to roll the change out.

You can delete a rule that's in use, but the confirmation lists every router affected, and those steps are left without a rule.
