Project

General

Profile

API - CallQueue Save

CallQueue / Save API is used to schedule calls that will be dialed later, according to a predefined schedule, using Originate call.

API URL

https://[YOUR-PBX-URL]/api/call-queue

Data is sent via POST or GET and must be of the form:

Array
(
    [action] => save
    [data] => Array
        (
            [project_id] => 1
            [type] => queue
            [destination] => test-queue
            [campaign_name] => Test campaign
            [campaign_info] => Some special info
            [outbound_type] => auto
            [attend_type] => attended
            [outbound_number] => +40212345678
            [outbound_trunk] => default-trunk
            [calls] => Array
                (
                    [0] => Array
                        (
                            [caller_id] => 0123456789
                            [caller_id_name] => John Doe
                            [priority] => 0
                            [schedule] => 
                            [external_id] => asdf1234
                            [max_retries] => 5
                            [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] => 20b093246dac88454f390553e813aa0d
)

The action parameter must have the value save (if missing, it defaults to save)

Parameters:

  • project_id: project ID in the PBX, mandatory
  • type: type of the destination the internal call is sent to (user, queue, context), mandatory
  • destination: the PBX user / queue / context for which the call is initiated, mandatory. For user and queue, their existence in the PBX is checked
  • campaign_name: campaign name, mandatory
  • campaign_info: additional campaign information, mandatory
  • outbound_type: automatic or manual campaign type (auto, manual), mandatory
  • attend_type: the call is made with or without an agent (attended, unattended), mandatory
  • outbound_number: the number that is displayed to the recipient, optional; defaults to the project's outbound number
  • outbound_trunk: the provider through which the call is made, optional; defaults to default-trunk
  • calls: array with the calls, mandatory
    • caller_id: the phone number that is called, mandatory; only digits and + are kept
    • caller_id_name: the name of the person who is called, mandatory
    • external_id: ID from the external database (eg: activity ID), mandatory
    • priority: the call priority in the call queue, optional, default 0
    • schedule: the date and time the call is scheduled for, optional, defaults to the current date and time. Format: Y-m-d H:i:s (eg: 2017-02-16 00:00:00)
    • max_retries: the maximum number of attempts before the call is abandoned, optional, defaults to the value set in the project
    • vars: array with various variables for the PBX context, optional

Each call in calls is processed separately: valid calls are saved even if others have errors (has_error = true). The keys in results and messages are the index of the call in calls, so always check results.

A call is considered a duplicate (and is not saved) if there is already a waiting one (pending / inprogress) with the same caller_id, project_id and external_id and with the same destination of the Inbound route associated with outbound_number (if any).

HTTP Headers:

Content-Type: application/json
Authorization: Bearer <token>

Example of parameters generation:

$params = array(
    'action' => 'save',
    'data' => array(
        'project_id' => 1,
        'type' => 'queue', // user, queue, context
        'destination' => 'test-queue',
        'campaign_name' => 'Test campaign',
        'campaign_info' => 'Some special info',
        'outbound_type' => 'auto', // auto, manual
        'attend_type' => 'attended', // attended, unattended
        'outbound_number' => '+40212345678', // dnid
        'outbound_trunk' => 'default-trunk',
        'calls' => array(
            array(
                'caller_id' => '0123456789',
                'caller_id_name' => 'John Doe',
                'priority' => 0,
                'schedule' => '', // default NOW()
                'external_id' => 'asdf1234',
                'max_retries' => 5,
                '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(json_encode($params) . 'your_api_key'); // make hash

Example of sending data:

$url = 'https://[YOUR-PBX-URL]/api/call-queue';
$token = 'your_api_token';
echo curlPost($url, json_encode($params), array("Authorization: Bearer {$token}", "Content-Type: application/json"));

Data sent JSON

{
  "action": "save",
  "data": {
    "project_id": 1,
    "type": "queue",
    "destination": "test-queue",
    "campaign_name": "Test campaign",
    "campaign_info": "Some special info",
    "outbound_type": "auto",
    "attend_type": "attended",
    "outbound_number": "+40212345678",
    "outbound_trunk": "default-trunk",
    "calls": [
      {
        "caller_id": "0123456789",
        "caller_id_name": "John Doe",
        "priority": 0,
        "schedule": "",
        "external_id": "asdf1234",
        "max_retries": 5,
        "vars": {
          "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": "19a84b02b61cb907611cd986f10062db" 
}

Response

If successful:

{

    "has_error": false,
    "messages": [ ],
    "results": [
        {
            "external_id": "asdf1234",
            "queue_id": 79,
            "schedule": "2017-02-20 15:22:32" 
        }
    ]

}

Or in case of error:

{

    "has_error": true,
    "messages": {
        "0": "row #0 is already scheduled with queue_id #78",
        "schedule::1": "Invalid schedule (1), format must be Y-m-d H:i:s" 
    },
    "results": [ ]

}

Available in other languages: RO