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 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
);

Last updated