# Outbound routing

Outgoing routes in MikoPBX are a set of rules and settings that determine how the system handles outgoing calls from employees to external numbers. With their help, administrators can control the direction of calls through different telephony providers or communication lines depending on certain conditions, such as the dialed number, prefixes, time of day or user access rights. This allows you to optimize communication costs, distribute the load between channels and apply security policies by restricting or allowing certain types of calls. Setting up outgoing routes provides flexibility and control over outgoing telephone communications, contributing to the efficient operation of the company's communication system.

In this article, you will find detailed documentation on setting up outgoing routing.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FgzFLFDMv2OVPcTE2jRk5%2FOutboundRoutingSection.png?alt=media&#x26;token=514cad6b-4702-4c4b-a788-275693a2e8e8" alt=""><figcaption><p>"Call routing" -> "Outbound routing" section</p></figcaption></figure>

## Creating a rule

{% hint style="info" %}
Additional examples of configuring outgoing routing are available in the [FAQ ](https://docs.mikopbx.com/mikopbx/english/faq/outbound-routing)section.
{% endhint %}

### Step 1: Add a new rule

To add a new outgoing routing rule, click the "**Add a new rule"** button.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FKQcnFUACGEIWehxLhL3H%2FAddANewRule.png?alt=media&#x26;token=c7431a1c-37c2-4cd3-969d-32116ae92e84" alt=""><figcaption><p>New rule in outbound routing</p></figcaption></figure>

### Step 2: Title and Note

The name of the rule can be set arbitrarily.

&#x20;In a note, you can describe the call route that you want to implement; this can help you in debugging in the future.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FNIOQVM5VS0hB87AvDoV2%2FStep1CreatingANewRule.png?alt=media&#x26;token=d3974e93-e9e5-480c-879a-be559eee4819" alt=""><figcaption><p>Step 2: Title and Note</p></figcaption></figure>

### Step 3. Setting the number template

Set a template for outgoing calls. Read more about number templates in this [articles group](https://docs.mikopbx.com/mikopbx/english/faq/outbound-routing/number-templates).

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2Fr4bF10Bi9Q8zEjQSpYcS%2FStep2CreatingANewRule.png?alt=media&#x26;token=c3475b12-873d-438e-8c32-1ff5107d7da8" alt=""><figcaption><p>Step 3: Setting the number template</p></figcaption></figure>

The example in the picture above means the following: if the dialed number starts with "**345**" or "**375**" and the rest of the number consists of **10 digits.**

{% hint style="warning" %}
If the dialed number matches the rules of several routes, then the call will be made in the order of the route descriptions, one by one, until the call is answered, or until there are no more suitable routes.
{% endhint %}

### Step 4: Number Conversion

Convert number - this setting is intended to remove the number prefix and replace it with the desired prefix.

Set a template for outgoing calls. Read more about number templates in the [next paragraph](#primery-shablonov-nomerov).

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FNzB8pRuxydv8YQADKtHi%2FStep3CreatingANewRule.png?alt=media&#x26;token=9783da4b-2d05-4488-aff0-d19aeae01328" alt=""><figcaption><p>Step 4: Number Conversaion</p></figcaption></figure>

In the example given, digits **are not cut off at the beginning of the number and digits are not added.**

### Step 5. Selecting a provider

Select from the list the provider for which you configured outgoing routing and save the changes.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FvYd4wp7baR0Bnv9waYAk%2FStep4CreatingANewRule.png?alt=media&#x26;token=d8650df3-9ad9-4807-abd7-0c4d5221abc4" alt=""><figcaption><p>Step 5: Selecting a provider</p></figcaption></figure>

## Examples

### Examples of number templates

<table data-full-width="true"><thead><tr><th width="262">The number starts with</th><th width="536.3333333333333">The rest of the number consists of the specified number of digits</th><th>Examples of numbers</th></tr></thead><tbody><tr><td>[7-8]{1}</td><td>10</td><td>79257184255, 84952293042</td></tr><tr><td>7925</td><td>leave the field blank</td><td>79257184255, 7925, 7925718…</td></tr><tr><td>7ХХ</td><td>0</td><td>700, 701, 702…</td></tr><tr><td>74952293042</td><td>0</td><td>74952293042</td></tr><tr><td>74(95|99)</td><td>7</td><td>74952293042, 74996382584…</td></tr><tr><td>(7|8)0{1}</td><td>1</td><td>700, 701, 802, 803…</td></tr><tr><td>(25|26)</td><td>0</td><td>25, 26</td></tr><tr><td>[0-9]{1}</td><td>0</td><td>digit from 0 to 9, occurrence once</td></tr><tr><td>[1-5]{2}</td><td>0</td><td>12, 15, 14, 25 digit from 1 to 5, occurrence twice</td></tr><tr><td>[8-9]+</td><td>0</td><td>8899, 888, 988888 digit from 8 to 9, occurrence one or more times</td></tr></tbody></table>

### Examples of changing number prefixes

#### Example 1. It is necessary to replace the number prefixes “+7” with “8”.

For example, the number **+7**4952293042 should be converted to the number **8**4952293042.

The implementation of the rule looks like this:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FzTyGMuyBiUOGkUOnBlVY%2F%2B7to8.png?alt=media&#x26;token=cbb7cae9-f276-4a90-b3bb-2a824f8a6c20" alt=""><figcaption><p>+7 to 8</p></figcaption></figure>

#### Example 2. It is necessary to replace the number prefixes “8”, “7” with “+7”.

For example, the numbers **8**4952293042 and **7**4952293042 should be converted to **+7**4952293042.

The implementation of the rule looks like this:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FKuyJNp2FfDM3zvixoz4d%2F7or8to%2B7.png?alt=media&#x26;token=c6b4ce00-326b-46a3-8bcf-b3061f540ff3" alt=""><figcaption><p>7 and 8 to +7</p></figcaption></figure>

#### Example 3: You need to add the prefix "8" to the number.

For example, the numbers 4952293042 and 4996382584 should be converted to **8**4952293042 and **8**4996382584 respectively.

The implementation of the rule looks like this:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FPi2eEStlquMRthG3H0VC%2Fprefix8.png?alt=media&#x26;token=a9f99f6f-8d8b-49f7-9e80-d9256d08e0e8" alt=""><figcaption><p>Prefix 8</p></figcaption></figure>

#### Example 4: You need to remove the area code "8495" or "7495" or "8499" or "7499" and leave the 7-digit number.&#x20;

For example, the numbers 84952293042 and 74996382584 should be converted to 2293042 and 6382584 respectively.

The implementation of the rule looks like this:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FrB3AKzYYgO3k50WhW3HF%2FremovePrefix.png?alt=media&#x26;token=667d7469-c577-4ced-a38f-89526bdf0eb7" alt=""><figcaption><p>Remove prefix</p></figcaption></figure>
