Campaign API¶
-
CampaignSerializer
¶ Create:
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "mycampaign01", "description": "", "callerid": "1239876", "startingdate": "2017-01-01 13:13:33", "expirationdate": "2017-06-14 13:13:33", "frequency": "10", "max_aleg":28, "max_xfer":12, "dial_method":2, "agent_dial_rate":1.2, "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/2/", "sms_gateway": "", "object_id" : "101", "extra_data": "2000", "voicemail": "True", "amd_behavior": "1", "voicemail_audiofile": "", "dnc": "", "user": "/rest-api/users/1/", "phonebook": ["/rest-api/phonebook/1/"], "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "callerid_group": "/rest-api/callerid_group/7/"}' http://HOSTNAME_IP/rest-api/campaigns/
Response:
HTTP/1.0 201 CREATED Date: Fri, 14 Jun 2013 09:52:27 GMT Server: WSGIServer/0.1 Python/2.7.3 Vary: Accept, Accept-Language, Cookie Content-Type: application/json; charset=utf-8 Content-Language: en-us Allow: GET, POST, HEAD, OPTIONS {"id": 1, "campaign_code": "JDQBG", "name": "mycampaign1", "description": "", "callerid": "1239876", "phonebook": ["/rest-api/phonebook/1/", "/rest-api/phonebook/2/"], "startingdate": "2016-01-13T13:13:33", "expirationdate": "2016-01-14T13:13:33", "aleg_gateway": "http://HOSTNAME_IP/rest-api/gateway/1/", "user": "http://<IP-HOST>/rest-api/users/1/", "status": 2, "object_id": 1, "extra_data": "2000", "dnc": null, "frequency": 20, "callmaxduration": 50, "maxretry": 3, "intervalretry": 3000, "calltimeout": 45, "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": true, "sunday": true, "completion_enabled": true}
Create a campaign with an Survey/IVR:
In order to create a campaign with a Survey/IVR, you have to provide the parameter object_id. The object_id is the survey template ID that you can find in your Modules->Survey/IVR, the ID is in the link when editing the survey.
Curl example to create a campaign with IVR/Survey:
curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "campaign-with-survey", "description": "", "callerid": "1239876", "startingdate": "2020-08-01 14:13:33", "expirationdate": "2020-08-30 13:13:33", "frequency": "10", "max_aleg":28, "max_xfer":12, "dial_method":2, "agent_dial_rate":1.2, "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/2/", "sms_gateway": "", "object_id" : "9", "extra_data": "2000", "voicemail": "True", "amd_behavior": "1", "voicemail_audiofile": "", "dnc": "", "user": "/rest-api/users/1/", "phonebook": ["/rest-api/phonebook/1/"], "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "callerid_group": "/rest-api/callerid_group/7/"}' http://HOSTNAME_IP/rest-api/campaigns/
When a campaign is created, the campaign status is New.
If you wish to start it using the API, you can use the Update Campaign API, as follow:
curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"status": 1}' http://HOSTNAME_IP/rest-api/campaigns/175/
Read:
CURL Usage:
curl -u areski:areski -H 'Accept: application/json' http://127.0.0.1:8000/rest-api/campaigns/ curl -u username:password -H 'Accept: application/json' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/
Response:
{ "count": 1, "next": null, "previous": null, "results": [ { "id": 2, "campaign_code": "TANCW", "name": "TestCampaign", "description": null, "callerid": "123234242", "caller_name": "", "callerid_group": "http://127.0.0.1:8000/rest-api/callerid_group/7/", "phonebook": [ "http://HOSTNAME_IP/rest-api/phonebook/1/" ], "startingdate": "2017-02-23T16:17:14+01:00", "expirationdate": "2017-02-24T16:17:14+01:00", "aleg_gateway": "http://HOSTNAME_IP/rest-api/gateway/1/", "user": "http://HOSTNAME_IP/rest-api/users/1/", "status": 4, "object_id": 1, "extra_data": "", "dnc": "http://HOSTNAME_IP/rest-api/dnc/1/", "voicemail": false, "amd_behavior": 1, "voicemail_audiofile": null, "voicemail_tts": null, "frequency": 10, "max_aleg": 0, "max_xfer": 0, "dial_method": 1, "agent_dial_rate": "1.00", "callmaxduration": 1800, "maxretry": 0, "intervalretry": 300, "calltimeout": 45, "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": true, "sunday": true, "completion_enabled": false, "sms_gateway": "http:\/\/127.0.0.1:8000\/rest-api\/sms-gateway\/2\/", "record_bleg": false, "record_call": false, "timezone_dialing": false, "archived": false, "tts_language": "en", "unavailable_audiofile": null, "route_type": 1, "route_audiofile": null, "route_tts": null, "xfer_gateway": null, "xfer_phonenumber": null, "has_been_started": false, "has_been_duplicated": false, "duplicated_from": null, "callcenter_config": null, "campaign_type": 1, "api_available_agent": null, "get_progress_bar_values": { "progress_string": "7/8 contact(s) dialed! (Dialed:7; DNC:0; Unauthorized:0)", "percentage": "87.5%", "progress_classname": "progress-bar progress-bar-success" } } ] }
Update:
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"name": "mylittlecampaign243"}' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/
Response:
HTTP/1.0 202 NO CONTENT Date: Fri, 23 Sep 2011 06:46:12 GMT Server: WSGIServer/0.1 Python/2.7.1+ Vary: Accept-Language, Cookie Content-Length: 0 Content-Type: text/html; charset=utf-8 Content-Language: en-us {"id": 1, "campaign_code": "JDQBG", "name": "mylittlecampaign243", "description": "", "callerid": "1239876", "phonebook": ["http://HOSTNAME_IP/rest-api/phonebook/1/", "http://<IP-HOST>/rest-api/phonebook/2/"], "startingdate": "2016-01-13T13:13:33", "expirationdate": "2016-01-14T13:13:33", "aleg_gateway": "http://<IP-HOST>/rest-api/gateway/1/", "user": "http://<IP-HOST>/rest-api/users/1/", "status": 2, "object_id": 1, "extra_data": "2000", "dnc": null, "frequency": 20, "max_aleg":50,"max_xfer":5,"dial_method":2,"agent_dial_rate":3.6, "callmaxduration": 50, "maxretry": 3, "intervalretry": 3000, "calltimeout": 45, "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": true, "sunday": true, "completion_enabled": false}
CURL Usage (Update Campaign Status==Started):
curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"status": 1}' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/
Create Callcenter Campaign:
CallCenter campaigns have 3 extra parameters that normal IVR campaign don’t have: queue, callcenter_config & campaign_type.
Campaign_type: This needs to be set to 3, this will set the campaign as Callcenter campaign.
Queue: This is the queue to use for the callcenter Campaign.
CallCenter Config: This is the Callcenter config, this configures the script to use, CRM external URLs, etc…
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "callcenter-campaign-01", "description": "", "callerid": "1239876", "startingdate": "2017-01-01 13:13:33", "expirationdate": "2017-06-14 13:13:33", "frequency": "10", "max_aleg":28, "max_xfer":12, "dial_method":2, "agent_dial_rate":1.2, "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/2/", "sms_gateway": "", "object_id" : "101", "extra_data": "2000", "voicemail": "True", "amd_behavior": "1", "voicemail_audiofile": "", "dnc": "", "user": "/rest-api/users/1/", "phonebook": ["/rest-api/phonebook/1/"], "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "queue":"/rest-api/queue/6/","callcenter_config":"/rest-api/callcenter_config/1/","campaign_type":3}' http://HOSTNAME_IP/rest-api/campaigns/
Response:
HTTP/1.0 201 CREATED Date: Fri, 14 Jun 2013 09:52:27 GMT Server: WSGIServer/0.1 Python/2.7.3 Vary: Accept, Accept-Language, Cookie Content-Type: application/json; charset=utf-8 Content-Language: en-us Allow: GET, POST, HEAD, OPTIONS {"id":163,"campaign_code":"KTYIZZPXFO","name":"callcenter-campaign-05","description":"","callerid":"1239876","phonebook":["/rest-api/phonebook/1/"],"startingdate":"2017-01-01T13:13:33+01:00","expirationdate":"2017-06-14T13:13:33+02:00","aleg_gateway":"/rest-api/gateway/2/","user":"/rest-api/users/1/","status":0,"object_id":21,"extra_data":"2000","dnc":null,"voicemail":true,"amd_behavior":1,"voicemail_audiofile":null,"voicemail_tts":null,"frequency":10,"max_aleg":28,"max_xfer":12,"dial_method":2,"agent_dial_rate":"1.20","callmaxduration":50,"maxretry":3,"intervalretry":3000,"calltimeout":45,"daily_start_time":"00:00:00","daily_stop_time":"23:59:59","monday":true,"tuesday":true,"wednesday":true,"thursday":true,"friday":true,"saturday":true,"sunday":true,"completion_enabled":false,"sms_gateway":null,"record_bleg":false,"record_call":false,"timezone_dialing":false,"archived":false,"tts_language":"en","unavailable_audiofile":null,"route_type":1,"route_audiofile":null,"route_tts":null,"xfer_gateway":null,"xfer_phonenumber":null,"has_been_started":false,"has_been_duplicated":false,"duplicated_from":null,"queue":"/rest-api/queue/6/","callcenter_config":"/rest-api/callcenter_config/14/","campaign_type":3}