# Change phone number before sending data to CRM

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

If necessary, you can change the phone number received from the PBX before sending data to CRM.

This will be useful if you want:

This will be useful if you want to:

* Automatically add the area code to short numbers dialed by employees;
* Replace 7 with 8 at the beginning of the number, if incoming calls are recorded from 7;
* Add 8 at the beginning of the number, if incoming calls come without 8...

Editing the file **/opt/itgrix\_bx/customizer/actions/process\_phone\_number.php**.

### Example of trimming a number and substituting 8 at the beginning

In the following example, for all numbers of 10 characters or more, CRM will get a number at the beginning of which will be 8, and at the end - the last 10 digits of the original phone number:

* 4991234567 will be replaced with 84991234567&#x20;
* 1234567 will be unchanged&#x20;
* 39974991234567 will be replaced with 84991234567&#x20;
* 74991234567 will be replaced with 84991234567&#x20;
* +74991234567 will be replaced with 84991234567

```
$phone = $params['phone'];

// Getting the last 10 digits of the number
if(preg_match('/([0-9]{10})$/', $phone, $match)){
// if the number has 10 digits at the end, then add an eight to the beginning
    $phone = '8' . $match[1];
}

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


---

# 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-phone-number-before-sending-data-to-crm.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.
