Web API description

 

Table of contents:

1. General description

2. Module "autocall"

3. Moule "polls"

 

1. General description:

Web API is available starting from pbxunit version 1.2.6

A request to web api occurs by sending an http request using the POST method to the address http://<server address>/pbxunit/api/

The request must pass variables:

key - secret key it's stored in web interface configuration file in the $ _AST_CONFIG ['APIKey'] variable

$_AST_CONFIG['APIKey'] = 'secretkey';

Attention! For security, change the key after installation.

comm - command

params - JSON parameters

 

In response to the request, the answer will be in JSON format

{"code": response code, "code_text": "response text", "values": {values}}

options code:

200 OK - Request completed

401 Unauthorized - Unauthorized access

400 Bad Request - Invalid request format

403 Forbidden - Access is denied

 

2. Module "autocall"

Command ac_job_add - add task

params block:

camp_id (required) - auto-call campaign id

phones (required) - list of phones separated by ";"

worksh_id - worksheet id

task_name - task name 

tts_text - text for speech generator, phrases are separated by ";"

example:

comm ac_job_add

params {"camp_id": "8", "phones": "79120000000", "worksh_id": "test", "task_name": "test"}

respone {"code":200,"code_text":"OK","values":{"insert_id":1502162}}

returns the id of the added job in the variable insert_id

 

Command ac_job_pause - pause the task

params block:

job_id (required) - autocall task id

sample:

comm ac_job_pause

params {"job_id": "1401041"}

respone {"code":200,"code_text":"OK","values":{"change_id":"1401041"}}

returns the id of the changed job in the variable change_id

 

Command ac_job_run - resume the job

params block:

job_id (required) - autocall task id

sample:

comm ac_job_run

params {"job_id": "1401041"}

respone {"code":200,"code_text":"OK","values":{"change_id":"1401041"}}

returns the id of the changed job in the variable change_id

 

Command ac_job_del - delete the auto dialing task

params block:

job_id (required) - autocall task id

sample:

comm ac_job_del

params {"job_id": "1401041"}

respone {"code":200,"code_text":"OK","values":{"change_id":"1401041"}}

returns the id of the changed job in the variable change_id

 

Command ac_job_get_status - get job status

params block:

job_id (required) - autocall task id

sample:

comm ac_job_get_status

params {"job_id": "1502159"}

respone {"code":200,"code_text":"OK","values":{"id":"1502159","worksh_id":"1005576","phones":"9120000001;9120000002","name":""\u0410\u041b\u0422\u0410\u0419\u042d\u041d\u0415\u0420\u0413\u041e\u041f\u0420\u0418\u0412\u041e\u0414" \u041e\u041e\u041e","result_date":"0000-00-00 00:00:00","result":"","status":"Inqueue","attempts_cnt":"0","answered_cnt":"0","listened_cnt":"0","noanswer_cnt":"0","busy_cnt":"0","failed_cnt":"0"}}

 

Command ac_jobs_search_status - search for tasks by parameters

params block:

camp_id (required) - autocall campaign id

limit (optional) - limit of rows of the returned result (default is 1000 lines)

job_id (optional) - autocall task id

worksh_id (optional) - search in the field "Worksheet column"

result (optional) - search by Result of the task, options:

1 - Answered

2 - No anwswered

3 - Busy

4 - Failed

status (optional) - search by job status, options:

Inwork

Finished 

Inqueue

sample:

comm ac_jobs_search_status

params {"camp_id": "7", "status":"Inqueue"}

respone {"code":200,"code_text":"OK","values_ar":[

{"id":"1401050","worksh_id":"1","phones":"79120000001","name":"Test1","result_date":"2018-09-10 11:56:20","result":"Busy","status":"Inqueue","attempts_cnt":"216","answered_cnt":"107","listened_cnt":"95","noanswer_cnt":"17","busy_cnt":"56","failed_cnt":"27"},{"id":"1401051","worksh_id":"2","phones":"79120000002","name":"Test2","result_date":"2018-09-07 10:33:47","result":"Answered","status":"Inqueue","attempts_cnt":"184","answered_cnt":"115","listened_cnt":"97","noanswer_cnt":"4","busy_cnt":"14","failed_cnt":"33"},{"id":"1502175","worksh_id":"3","phones":"79120000003","name":"Test1","result_date":"2018-09-17 18:45:54","result":"Busy","status":"Inqueue","attempts_cnt":"10","answered_cnt":"3","listened_cnt":"2","noanswer_cnt":"3","busy_cnt":"3","failed_cnt":"0"},{"id":"1502176","worksh_id":"4","phones":"79120000004","name":"\u0422\u0435\u0441\u0442 1","result_date":"2018-10-25 10:40:20","result":"Answered","status":"Inqueue","attempts_cnt":"2","answered_cnt":"1","listened_cnt":"1","noanswer_cnt":"0","busy_cnt":"1","failed_cnt":"0"},{"id":"1502177","worksh_id":"5","phones":"79120000005","name":"test","result_date":"2018-10-30 23:43:38","result":"Answered","status":"Inqueue","attempts_cnt":"5","answered_cnt":"5","listened_cnt":"5","noanswer_cnt":"0","busy_cnt":"0","failed_cnt":"0"} ]}

 

3. Module "Polls"

Command poll_search_res - search poll results by parameters

The command is available starting from version 1.2.9

params block:

poll_id (required) - poll id

limit (optional) - limit of rows of the returned result (default is 1000 lines)

id (optional) - internal id of the poll result

quest_id (optional) - question result id

autocall_id (optional) - id of autocall setting at which the question occurred

autocallcampaing_id (optional) - id of the autocall campaign where the question occurred

res (optional) - the numerical result of the question

phone (optional) - the phone number for the question

sample:

comm poll_search_res

params {"poll_id": "7", "quest_id":"14", "autocallcampaing_id":"7"}

respone {"code":200,"code_text":"OK","values_ar":

[{"id":"39","date":"2018-02-03 21:32:40","phone":"79120000001","poll_id":"7","quest_id":"14","autocall_id":"1401033","autocallcampaing_id":"7","res":"1"},{"id":"40","date":"2018-02-03 21:33:14","phone":"79120000001","poll_id":"7","quest_id":"14","autocall_id":"1401034","autocallcampaing_id":"7","res":"0"},{"id":"41","date":"2018-02-04 11:43:15","phone":"79120000001","poll_id":"7","quest_id":"14","autocall_id":"1401034","autocallcampaing_id":"7","res":"0"},{"id":"42","date":"2018-02-04 11:44:18","phone":"79120000001","poll_id":"7","quest_id":"14","autocall_id":"1401034","autocallcampaing_id":"7","res":"1"},{"id":"43","date":"2018-02-04 11:45:12","phone":"79120000001","poll_id":"7","quest_id":"14","autocall_id":"1401034","autocallcampaing_id":"7","res":"0"} ]}