This functionality is convenient for mobile employees. When it is important that the conversation is recorded and recorded on the PBX in the call history. When it is not possible to use a softphone / or "IP-SIM".
- Add a new dialplan application (see Dialplan Applications)
Dialplan applications section
- Assign an internal number, for example 2200109
Dialplan Number
- Paste the code into the "Programme Code" tab:
<?php
namespace MikoPBX\Core\System;
require_once('Globals.php');
use MikoPBX\Common\Models\ExternalPhones;
use MikoPBX\Core\Asterisk\AGI;
use Phalcon\Mvc\Model\Resultset;
$agi = new AGI();
$number = substr($agi->request['agi_callerid'],-10);
if(strlen($number) < 7){
$agi->noop('Count < 7');
//Checking for the length of the number.
exit(0);
}
$outPhone = ExternalPhones::findFirst([
'conditions' => 'dialstring LIKE :number:',
'bind' => [
'number' => "%$number",
],
'hydration' => Resultset::HYDRATE_ARRAYS,
]);
if(count($outPhone) !== 1){
$agi->noop('ExternalPhones not found '.$number);
// Checking whether the phone number belongs to an employee of the company.
exit(0);
}
$agi->set_variable('AGIEXITONHANGUP', 'yes');
$agi->set_variable('AGISIGHUP', 'yes');
$agi->set_variable('__ENDCALLONANSWER', 'yes');
$agi->exec('Ringing', '');
$agi->Answer();
$result = $agi->getData('vm-enter-num-to-call', 3000, 11);
$selectednum = $result['result']??'';
if(!empty($selectednum)){
// Everything is OK. Ending the call.
$agi->set_variable('__pt1c_UNIQUEID', '');
$agi->exec(
'Dial',
"Local/{$selectednum}@all_peers/n,300," . 'TtekKHhU(dial_answer)b(dial_create_chan,s,1)'
);
}else{
$agi->noop('selectednum is empty');
}
Code for dialplan
- In the browser's address bar, copy the application ID. It will look like "DIALPLAN-APP-6A9902C631C5E7B5AC8F501C559FD678"
Dialplan ID
- Go to the "System file customization" section
System file customixation section
- Open the file "extensions.conf" for editing
"extensions.conf" file
- Paste the following code at the end of the file:
[add-trim-prefix-clid-custom]
exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup()
same => n,AGI(«DIALPLAN-APP-6A9902C631C5E7B5AC8F501C559FD678.php)
same => n,Return()
code for extensions.conf
{% hint style="info" %} here "DIALPLAN-APP-6A9902C631C5E7B5AC8F501C559FD678" is the application ID. {% endhint %}
- The application will be executed for all incoming calls
- It will be possible to enter an extension only if the caller's phone number is filled in the employee card, that is, the number must belong to the employee. This is done for security.
- The script is not a complete product, but is open for customization