# Routing

{% hint style="info" %}
*By using routing commands, you can divide your clients based on certain commands and preferences. Each client can be routed to* [*operator groups*](#group)*,* [*chatbot*](#chatbot)*, or* [*external number*](#external-number)*.*

*By prioritizing channels, you can ensure that certain communication channels take priority over others.*
{% endhint %}

## Routing targets

### Group

Routing can be set in the group **(By operator utilization** or **To whole group**). See the information found in the [group settings ](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/groups)section.

### Chatbot

If you have chosen a **chatbot** as a target, the session no longer falls into other groups. The chatbot is the first to create and connect with Mluvii. You can read about chatbot settings [here](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/chatbots).

### External number

This option is aimed for use in conjunction with [IP Telephony](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/ip-telephony). If the previous groups are unavailable (within the routing), the calling client is forwarded to the selected external telephone number.

{% hint style="success" %}
*As part of the routing setup, you can use an external number as one of the destinations, which you enter manually, or select a specific external contact from the menu. More details on routing settings can be found* [*here*](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/routing)*.*
{% endhint %}

## Routing rules

* **any or several conditions** - if multiple conditions are defined, all must be met at the same time. Interaction is routed only to groups that meet all defined conditions.
* **one group of operators or chatbot** - interactions directed here in case of met conditions.

Each routing target has a priority according to rank and sessions gradually decrease from the highest to the lowest priority routing targets

{% hint style="info" %}
*If you modify the conditions of the active routing, the changes will take effect immediately after saving.*
{% endhint %}

### Creating a routing rule

To create a new routing rule, click the **"Add "** button. Select a group to which the rule will apply. You can then set the handoff time interval in the [group settings](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/groups).

You can then use the *"Add Condition"* button to specify exactly under what conditions the handoff can occur. The settings for each [parameter ](https://docs.mluvii.com/en/for-it-specialists/customization/parameters)can be found in the [**Application**](https://docs.mluvii.com/en/for-administrators/tenant-management/settings/application) section.

#### Fallback

In case the routing is unable to find a suitable operator group given the configured routing conditions (because the group is not available or its queue is full), the session can be optionally routed to **fallback** (if enabled in the routing configuration).

a) Fallback is enabled

The session is routed to fallback groups. These are all the groups defined in the routing configuration, including groups that do not meet routing conditions. However, the group with the highest priority that satisfies the routing conditions is always preferred.

b) Fallback is disabled

The behavior is different for each channel.

| Communication channel                                                   |                                                                                           Behavior                                                                                           |
| ----------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| WebChat                                                                 |                                                                         The client is redirected to the offline form.                                                                        |
| IP Telephony                                                            | The information about the unavailability of the operator is passed to the PBX, which acts according to the IVR settings. For example, by playing the recorded message or by ending the call. |
| Facebook Messenger, WhatsApp, Apple Messages for Business and VKontakte |                                                                  Sezení čekají na dostupného operátora bez časového limitu.                                                                  |
| E-mail                                                                  |                     Email čeká na dostupného operátora bez časového limitu. Tenant administrátor a vyšší může e-mail z přehledu emailů přiřadit na libovolného operátora.                    |

{% hint style="info" %}

### *Routing rejection after working hours*

*The application automatically treats the situation when the client opens a chat just before the end of working hours and enters the chat session after working hours. When entering the queue, the application checks the availability of each operator and, if no one is online, redirects the client to the offline form.*
{% endhint %}

### Channel prioritization

Channel prioritization allows you to set the desired behavior in cases where clients from multiple different communication channels (e.g. chat sessions and phone calls) are queued at the same time.

As in the case of operator groups settings, you will find 3 communication channel groups (Live, Offline, and Email). You can specify channel priorities both at the individual communication channel level and between channel groups.

Within the routing of waiting sessions, you can also take into account the length of the waiting in the queue. This is done by using the **Increment** item in combination with the **Increment Interval**. As the time a session waits in the queue increases, it gets higher and higher priority and you won't have such sessions overtaken by new sessions.
