API - OriginateCall¶
Originate Call API is used to initiate calls to customers via logged extensions.
The process is done in three steps:¶
- Originate call: sending in PBX the destination number and the user
- Agent ring: the agent's phone calls, and when i's answered, advance to the next step
- Endpoint ring: PBX calls the destination number and when it is answered it is connected to the agent
API URL¶
https://[YOUR-PBX-URL]/api/originate-call
Data is sent via POST or GET and must be of the form:¶
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 [external_info] => some test call [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: destination phone number according to the PBX outbound rules, mandatory
- caller_id_name: recipient name, mandatory
- type: action type - user, queue, context, user_email, mandatory
- destination: user / queue / context in PBX for which the call is initiated, mandatory
- external_id: ID from the third party own application, used for further queries, mandatory
- external_info: informative text for the description of external_id
- async: if 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
Please note: if the async option is 1, the API will return successfully if the user is online (it is not guaranteed that the user has answered). If the async option is 0 API will keep the connection open until timeout, answer or reject is received from the user, returning error or success depending on the user's action.
Example of parameters generation:
$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',
'external_info' => 'some test call',
'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 generation:
$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash
Example for data sending:
$url = 'https://[YOUR-PBX-URL]/api/originate-call';
header('Content-Type: application/json');
echo curlPost($url, $params);
Answer¶
If successful:
{
"has_error": false,
"messages": [ ],
"results": [
{
"originate_result": "Call successfully originated for queue: test-queue"
}
]
}
Or in case of error:
{
"has_error": true,
"messages": [
"Invalid Queue. Check if pbx queue exists"
],
"results": [ ]
}
Available in other languages: RO
Go to top