Calls API
Tovie DialogStudio provides a Calls API you can use to integrate Tovie DialogStudio telephony service with any external system.
With the help of Calls API you can:
- start call campaigns;
- add numbers to your database;
- get reports for phone numbers and specific campaign tasks.
Getting started
Before starting your work with the Calls API, you need to:
API methods
Calls API provides the following methods.
-
Adding phone numbers to the campaign list.
POST https://ds.tovie.ai/api/calls/campaign/{token}/addPhones
-
Adding phone numbers from CRM to the campaign list.
GET https://ds.tovie.ai/api/crmCalls/campaign/{token}/addPhone
POST https://ds.tovie.ai/api/crmCalls/campaign/{token}/addPhone
GET https://ds.tovie.ai/api/crmCalls/campaign/{token}/test/addPhone
-
Canceling previously created call jobs.
POST https://ds.tovie.ai/api/calls/campaign/{token}/callJob/cancel
-
Pausing, resuming, and stopping the campaign.
POST https://ds.tovie.ai/api/calls/campaign/{token}/control/pause
POST https://ds.tovie.ai/api/calls/campaign/{token}/control/resume
POST https://ds.tovie.ai/api/calls/campaign/{token}/control/stop
-
Retrieving call campaign information.
GET /api/calls/campaign/{token}
GET /api/calls/campaign/{token}/status
-
Getting reports by call job ID or by phone number.
POST https://ds.tovie.ai/api/calls/campaign/{token}/callJob/getReport
POST https://ds.tovie.ai/api/calls/campaign/{token}/callAttempt/getReport
Calls API token
All Calls API requests must contain the {token}
parameter — a unique identifier providing API access. The new token is generated every time you create a new call campaign from a CRM system.
You can copy the token on the call campaign page:
- Go to the Outbound calls tab.
- Click Create in the Campaign from CRM system section.
- In the Integration section, click Get token → Copy token.
Idempotence key
In order to control the consistency of the created resources, client applications can generate and pass an idempotence key in their requests to the Calls API.
If such requests contain no idempotence key or it is different between them, the requests are considered different and are not guaranteed to return equal results.
Passing the idempotence key
The GET method
For the GET /addPhone
method, the idempotence is passed as an Idempotence-Key
request parameter:
curl 'https://ds.tovie.ai/api/calls/campaign/8231.7056.1b131df1/addPhone?phone=16123456789&Idempotence-Key=d5f41bd4'
POST methods
All the POST
methods require passing the idempotence key in an Idempotence-Key
request header:
curl --request POST 'https://ds.tovie.ai/api/calls/campaign/8231.7056.1b131df1/addPhones' \
--header 'Content-Type: application/json' \
--header 'Idempotence-Key: d5f41bd4' \
--data-raw '[
{
"phone": 16123456789
}
]'
How to use
Passing the idempotency key in the request will help to avoid undesirable call duplicates in case of a technical error.
Suppose that a system failure causes a request to add a phone number to the campaign to be executed twice. The phone number and other data passed are identical in both requests.
- If the requests do not contain an idempotence key, the first created call job will be followed by a second with its ID distinct from the first, and they will both be put into the queue. Therefore, the bot will call to the specified number twice.
- If the requests have an idempotence key, then a duplicate call job will not be created. The second request will return the same call job ID as the first request and the bot will not call to the specified number twice.
Restrictions
No restrictions are imposed on the key format: it may be an arbitrary string. However, using UUIDs is recommended so that keys are guaranteed to be unique.