Audio file name customization
itgrix_bx (Bitrix24)
itgrix_kmo (Kommo)
/opt/itgrix_bx/customizer/actions/
/opt/itgrix_kmo/customizer/actions
Parameters
Input:
{
"call_id": “<Call ID>”,
"from": “<Caller number>”,
"to": “<The number to which the call came>”,
"path": “<Path to record>”
}
Return:
{
"data": {
"path": “<Customized path to record>”
},
"state": "success"
}
File before recording .wav
In case all records are stored in one directory and their names look like .wav, the following solution of file selection customization without DBMS access is possible:
$callId = $params['call_id'];
$from = $params['from'];
$to = $params['to'];
$path = $params['path'];
extract(pathinfo($path));
$path = $dirname . '/' . $callID . '.wav';
return array(
'state' => 'success',
'data' => array(
'path' => $path,
),
);
Complex file name for which data should be compiled from DBMS
Let's consider an example of customization for a format record: /var/spool/asterisk/monitor/<дата-время>-<from>-<to>-<Call ID>.<extension>
Example:
/var/spool/asterisk/monitor/20180330140245-321654987-154-1522395542.2897.mp3
In this case we can see that the file name consists of digits - date/time of call, incoming number, internal number and uniqueid of call, which are specified with hyphens. Let's get the missing data from the database.
$callId = $params['call_id'];
$from = $params['from'];
$to = $params['to'];
$path = $params['path'];
// If more parameters are needed to generate a file name,
// then they can be obtained in the database by making an additional query.
// Code example:
$dbResult = Utils::mysqliQuery(
"SELECT * FROM `cdr` WHERE `uniqueid` = '".$callId."' ORDER BY `calldate` DESC LIMIT 1",
true);
if ($dbResult === false) {
return array(
'state' => 'error',
'data' => 'Error during request in CDR',
);
}
if (empty($dbResult)) {
return array(
'state' => 'error',
'data' => "There are no records found in the CDR for the call '$callId'",
);
}
//Next, we compile the file name from the received data
$row = $dbResult[0];
$path = sprintf('/var/spool/asterisk/monitor/%s-%s-%s-%s.%s',
date('YmdHis', strtotime($row['calldate'])),
$row['src'],
$row['dst'],
$callId,
pathinfo($row['recordingfile'], PATHINFO_EXTENSION)
);
return array(
'state' => 'success',
'data' => array(
'path' => $path,
),
);
Last updated
Was this helpful?