How to link a callback query to PBX¶
Originate Call API is used to initiate calls to customers via extensions logged in PBX .
Three Steps Flow:¶
- Originate call: delivering to PBX the destination and user's number
- Agent ring: the agent's phone rings, and when answered moves to the next step
- Endpoint ring: PBX calls to the destination number and when it responds it is connected to with the agent
API URL¶
https://[YOUR-PBX-URL]/api/originate-call
Data is delivered using POST or GET and needs to be as it follows:¶
Array ( [api_username] => your_api_usr [api_password] => your_api_pass [data] => Array ( [project_id] => 1 [caller_id] => 0123456789 [caller_id_name] => John Doe [type] => queue [destination] => test-queue [external_id] => asdf1234 [async] => 1 [outbound_number] => +40212345678 [outbound_trunk] => default-trunk [vars] => Array ( [SKIP_WELCOME] => 1 [SKIP_WE_ARE_RECORDING] => 1 [SKIP_ENTER_QUEUE] => 0 [BACKEND_LINK] => https://[YOUR-EXTERNAL-CRM-URL]/?change_this_url=1234 ) ) [api_hash] => 0f25e797e72d0dbba96d2c571a7bd6ba )
Parameters:¶
- project_id: Project ID in PBX, mandatory
caller_id: the destination phone number according to the outbound rules in PBX, mandatory - caller_id_name: recipient name, mandatory
- type: tipul actiunii - user, queue, context, mandatory
- destination: the user/queue in PBX for which the call is initiated, mandatory
- external_id: The ID from partner's own application, used for subsequent queries, mandatory
- async: whether the operation is executed asynchronously or not, optional, by default 1
- outbound_number: the number that is displayed to the recipient, optional
- outbound_trunk: the provider through which the call is made, optional
- vars: array with different variables for PBX context, optional
Observation: if the async option is 1, the API will deliver SUCCESS if the user is online (it is not guaranteed that the user has answered). If the async option is 0 API it will keep the connection open until the TIMEOUT, ANSWER or REJECT is received from the user, delivering error or success depending on the user's action.
Example of parameters form:
$params = array(
'api_username' => 'your_api_usr',
'api_password' => 'your_api_pass',
'data' => array(
'project_id' => 1,
'caller_id' => '0123456789',
'caller_id_name' => 'John Doe',
'type' => 'queue', // user, queue, context
'destination' => 'test-queue',
'external_id' => 'asdf1234',
'async' => 1,
'outbound_number' => '+40212345678',
'outbound_trunk' => 'default-trunk',
'vars' => array(
'SKIP_WELCOME' => 1,
'SKIP_WE_ARE_RECORDING' => 1,
'SKIP_ENTER_QUEUE' => 0,
'BACKEND_LINK' => 'https://[YOUR-EXTERNAL-CRM-URL]/?change_this_url=1234', // for pop-up
)
)
);
Example of hash form:
$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash
Example of sending data:
$url = 'https://[YOUR-PBX-URL]/api/originate-call';
header('Content-Type: application/json');
echo curlPost($url, $params);
Answer¶
In case of success:
{
"has_error": false,
"messages": [ ],
"results": [
"Call successfully originated for queue: test-queue"
]
}
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid Queue. Check if pbx queue exists"
],
"results": [ ]
}
Go to top