# Change the number / context for calling to asterisk

## Contact us instead of reading the instructions

If you don't want to go into details, contact us. We will quickly help you and answer all questions!\
[Contact us](/contacts.md) in any convenient way.

## Initializing a call from CRM may not work for the following reasons:

* A phone number in CRM starts with a +;
* Asterisk is configured with special dialing, for example, you can call only after 9.

The logic of this refinement will be as follows: we will receive the last 10 characters (for Russia) and add the desired prefix to the result. In the example, the prefix will be the number 8.

To configure customization, you must include the customizer file in the module settings. Editing the file /opt/itgrix\_bx/customizer/actions/process\_originate\_params.php.

```
//parameters names as in the config
$phone = &$params['extension'];

//We get the last 10 digits of the number in $match
if(preg_match('~(\d{10})$~', $phone, $match)){
    //Adding a prefix to the found one
    $phone = '8' . $match[1];
}

return array(
    'state' => 'success',
    'data' => $params
);
```

There is a need to call through different contexts. In the example: calls from numbers (161, 162, 163) will go through the context custom-context-1; from numbers (141, 140) through the context custom-context-2; other calls will go through the standard context specified in the settings.

```
//parameters names as in the config
$phone = &$params['extension'];
$channel = explode('/', $params['channel']);

$contexts = array(
    'custom-context-1' => array(161, 162, 163),
    'custom-context-2' => array(141, 140),
);

foreach($contexts as $context => $phones){
    if(in_array($channel[1], $phones)){
        $params['context'] = $context;
        break;
    }
}

return array(
    'state' => 'success',
    'data' => $params
);
```


---

# Agent Instructions: 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:

```
GET https://docs.itgrix.com/custom_common/change-the-number-context-for-calling-to-asterisk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
