> For the complete documentation index, see [llms.txt](https://docs.mikopbx.com/mikopbx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mikopbx.com/mikopbx/faq/incoming-routing/choosing-a-provider-when-redirecting-to-a-mobile.md).

# Выбор провайдера при переадресации на мобильный

**Задача**: На АТС заведено несколько провайдеров А,Б,В,Г…\
Вызов поступает на MikoPBX через провайдера А.\
При наборе мобильного номера сотрудника вызов должен также идти через провайдера А.\
**Провайдер должен поддерживать более одного одновременного вызова.**

1. Перейдите в раздел **Система** → **Кастомизация системных файлов**

<figure><img src="/files/OBLUUE2A1IQhdNXngjti" alt=""><figcaption><p>Меню кастомизации системных файлов</p></figcaption></figure>

2. Откройте для редактирования конфигурационный файл **extensions.conf**.

<figure><img src="/files/ZMe4qhcH9ebpzuUxfZXU" alt=""><figcaption><p>Редактирование файла Extensions.conf</p></figcaption></figure>

3. Установите режим «**Добавлять в конец файла**». В черное окно добавьте следующий фрагмент кода:

```php
[all-outgoing-custom]
exten => _[0-9*#+a-zA-Z][0-9*#+a-zA-Z]!,1,NoOp(-)
    same => n,NoOp("${PROVIDER_ID}" --- "${ONLY_THIS_PROVIDER}")
    same => n,Set(NEED_RETURN=${UNDEFINED})
    same => n,ExecIf($["${ONLY_THIS_PROVIDER}x" == "x"]?return)
    same => n,ExecIf($["${PROVIDER_ID}" != "${ONLY_THIS_PROVIDER}"]?Set(NEED_RETURN=1))
    same => n,ExecIf($["${PROVIDER_ID}" != "${ONLY_THIS_PROVIDER}"]?Set(ROUTFOUND=${UNDEFINED}))
    same => n,Return()
    
[add-trim-prefix-clid-custom]
exten => _[0-9*#+a-zA-Z][0-9*#+a-zA-Z]!,1,NoOp(start check blacklist)
    same => n,ExecIf($["${CHANNEL(channeltype)}" == "PJSIP" ]?Set(__ONLY_THIS_PROVIDER=${CHANNEL(endpoint)}))
    same => n,Return()
```

<figure><img src="/files/8a67RElNCvIyiOO1UUbC" alt=""><figcaption><p>Код для extension.conf</p></figcaption></figure>

4. Для каждого провайдера необходимо описать [исходящий маршрут](/mikopbx/manual/routing/outbound-routing.md)
5. Заполните для сотрудников мобильные номера [см. документацию](/mikopbx/manual/telephony/extensions.md)
6. Ограничьте использование исходящих маршрутов для пользователей, используйте модуль «[Группы пользователей](/mikopbx/modules/miko/module-users-groups.md)»
7. Теперь если выходящий вызов направить на мобильный сотрудника, к примеру через [IVR меню](/mikopbx/manual/telephony/ivr-menu.md), то вызов будет направлен через того же провайдера, через которого пришел

{% hint style="warning" %}
ВНИМАНИЕ: Инструкции актуальны только для MikoPBX **2022.2.96**+
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mikopbx.com/mikopbx/faq/incoming-routing/choosing-a-provider-when-redirecting-to-a-mobile.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
