> For the complete documentation index, see [llms.txt](https://docs.itgrix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.itgrix.com/custom_common/change-phone-number-before-sending-data-to-crm.md).

# 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](/contacts.md) 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
* 1234567 will be unchanged
* 39974991234567 will be replaced with 84991234567
* 74991234567 will be replaced with 84991234567
* +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
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.itgrix.com/custom_common/change-phone-number-before-sending-data-to-crm.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.
