Movidesk API - Telephony - With queue control
19 min
Created by Heloisa Kopsch Hendges on 5/13/2018 5:18 PM
Updated by Karine Moreira on 9/24/2024 4:33 PM
Important: Our APIs have a limit of 10 requests per minute to ensure healthy behavior in their use. If you have a specific scenario that requires increasing the usage, please contact our support team for feasibility analysis. Learn more about API schedules and limits
https://api.movidesk.com/public/v1

Telephony - With queue control

          Throughout this documentation, the procedures for using the API that integrates telephone systems with Movidesk are described. If the APIs described in this documentation are used, Movidesk will control the queue of your telephone system. It is important that before using the API, you read the documentation for the telephony module (which you can find by clicking here). For each received call, there must be an API call identifying one of the following statuses: "Call ended", "Missed call", or "Call canceled". If this is not met, the records in the database related to the telephone calls will be incomplete.

 

Layout 

Received call

  URL:    /asterisk_receivedCall
  Methods: POST

 

Property Type Size Required Description
token Guid   ✓  Movidesk API key.
queueId int           10 ✓  Queue ID, must be the same as the one provided in the telephone group registration in Movidesk.
clientNumber string  128 ✓  Phone number making the call.
id string  256 ✓  Unique identifier of the call made. Note: It will only be possible to relate a unique call id to a ticket. Therefore, it will not be possible to associate a repeated id with a ticket.
callDate datetime UTC   Date of the received call.  The date provided must be in the format yyyy-MM-ddThh:mm and in UTC*. 

 

Transferred call

  URL:    /asterisk_transferedCall
  Methods: POST

 

Property Type Size Required Description
token Guid   ✓  Movidesk API key.
id string   256 ✓  Unique identifier of the call made. Must be the same as the one provided in the received call method. Note: It will only be possible to relate a unique call id to a ticket. Therefore, it will not be possible to associate a repeated id with a ticket.
branchLine string  128 ✓  Agent's extension to which the call will be transferred. Must be the same as returned by the received call method.
transferDate datetime UTC   Date of the call transfer.  The date provided must be in the format yyyy-MM-ddThh:mm and in UTC*. 

  

Completed call

  URL:    /asterisk_completedCall
  Methods: POST

 

Property Type Size Required Description
token Guid   ✓  Movidesk API key.
id string   256 ✓  Unique identifier of the call made. Must be the same as the one provided in the received call method. Note: It will only be possible to relate a unique call id to a ticket. Therefore, it will not be possible to associate a repeated id with a ticket.
link string  max   Link to the call recording. This will be included in the description of the action of the ticket related to the call.
completedDate datetime UTC   Date of the call completion.  The date provided must be in the format yyyy-MM-ddThh:mm and in UTC*. 

  

Missed call

  URL:    /asterisk_lostCall
  Methods: POST

 

Property Type Size Required Description
token Guid   ✓  Movidesk API Key.
id string   256 ✓  Unique identifier for the call made. Must be the same as the one provided in the received call method. Note: It will only be possible to relate a unique call id to a ticket. Thus, it will not be possible to associate a repeated id to a ticket.
link string  max   Link to the recording of the message left by the client. It will be included in the description of the action for the respective ticket related to the call.
completedDate datetime UTC   Call completion date.  The provided date must be in the format yyyy-MM-ddThh:mm and in UTC*. 

    

Canceled/abandoned call

  URL:    /asterisk_canceledCall
  Methods: POST

 

Property Type Size Required Description
tokenGuid ✓ Movidesk API Key.idstring  256✓ Unique identifier for the call made. Must be the same as the one provided in the received call method. Note: It will only be possible to relate a unique call id to a ticket. Thus, it will not be possible to associate a repeated id to a ticket.canceledDatedatetime UTC ✓Call cancellation/abandonment date.  The provided date must be in the format yyyy-MM-ddThh:mm and in UTC*. 

 

Update call recording link

  URL:    /setMadeCallLink
  Methods: POST

 

Property Type Size Required Description
token Guid   ✓  Movidesk API Key.
id string   256 ✓  Unique identifier for the call made. Must be the same as the one provided in the received call method. Note: It will only be possible to relate a unique call id to a ticket. Thus, it will not be possible to associate a repeated id to a ticket.
Link string 256    Link to the call recording. It will be included in the description of the action for the respective ticket related to the call.

   *UTC: Coordinated Universal Time (UTC) is the time standard from which all other time zones in the world are calculated. E.g.: If your time zone is Brasília (UTC-03:00) and the current time is 15:30, the UTC time will be 18:30.

 

Working with the data

To access the data, it is necessary to first generate an API key

To generate an API key (token), go to Movidesk, navigate to Settings / Account / Parameters, and on the environment tab click the "Generate new key" button if you don't have one created yet.
You can repeat this operation whenever you want to generate a new access key, but remember that generating a new key will make all programs using the old key stop working.

Flows that should be followed 

Happy path 

 

The central receives a phone call ->  The central makes an API call to the asterisk_receivedCall method -> Movidesk returns the extension of the agent available to take the call -> The central transfers the call to the extension and makes an API call to the asterisk_transferedCall method -> Movidesk automatically opens the call control screen for the agent to whom the call was transferred -> The central identifies that the call has ended and makes an API call to the asterisk_completedCall method -> Movidesk automatically closes the screen that was open for the agent and performs the necessary procedures on the ticket generated/associated with the call.

 

 Received call

POST: https://api.movidesk.com/public/v1/asterisk_receivedCall?
token=155cac97-f203-4bb8-86e1-aa4cb8781f3e&queueId=1&clientNumber=4733990777&id=3&callDate=2018-5-1T17:00:00

          Response: Status 200 with the extension of the agent available to take the call or a code indicating why the call cannot be transferred. At this point, the call will appear in Movidesk in the call queue waiting for attention. We suggest that when the returned code is 3 or 4, the central continues calling the asterisk_receivedCall method until the extension of an agent is returned. It is necessary that upon receiving the response with the extension, the central validates whether that extension is really available, as the agent themselves may have initiated a call and Movidesk will not have control over that. If the central considers the extension to be unavailable, another call to asterisk_receivedCall should be made, which always returns different extensions following the order established within Movidesk. If the central considers the call as missed, the asterisk_lostCall method should be called.

         Code identification:

         0 = It is a holiday;

         1 = Outside of working hours;

         2 = No agent from the group is online on Movidesk;

         3 = No agent from the group is online on the phone system;

         4 = All agents from the group are on a call.

 

Transferred call

POST: https://api.movidesk.com/public/v1/asterisk_transferedCall?
token=155cac97-f203-4bb8-86e1-aa4cb8781f3e&id=3&branchLine=5252&transferDate=2018-5-1T17:02:00

          Response: Status 200. At this moment, the call will appear in Movidesk in the ongoing calls queue, and the call control screen will automatically appear for the agent with the provided extension (in this example, 5252).

 

Completed call

POST: https://api.movidesk.com/public/v1/asterisk_completedCall?
token=155cac97-f203-4bb8-86e1-aa4cb8781f3e&id=3&link=https://www.linkdagravacaodachamada.com.br&completedDate=2018-5-1T17:20:00

          Response: Status 200. At this moment, the call will be removed from the Movidesk queues, and the call control screen will be automatically closed. The action with the call recording will be added to the ticket related to the call.

 

Alternative scenarios 

  1. The center receives a phone call -> The center makes an API call to the asterisk_receivedCall method -> Movidesk returns code 0 or 1 or 2 -> The center considers the call as missed, asks the customer to leave a message, and makes an API call to the asterisk_lostCall method -> Movidesk automatically generates a ticket with a missed call origin and generates an action in the ticket with the call description and a link to listen to the recording of the message left by the customer.
  2. The center receives a phone call -> The center makes an API call to the asterisk_receivedCall method -> Movidesk returns code 3 or 4 -> The center considers all agents to be busy but continues to make requests to the asterisk_receivedCall method until Movidesk returns the extension of the agent available to take the call -> The center transfers the call to the extension and makes an API call to the asterisk_transferedCall method -> Movidesk automatically opens the phone call control screen for the agent to whom the call was transferred -> The center identifies that the call has been completed and makes an API call to the asterisk_completedCall method -> Movidesk automatically closes the screen that was open for the agent and performs the necessary actions on the generated/associated ticket for the call.
  • The center receives a phone call -> The center makes an API call to the asterisk_receivedCall method -> Movidesk returns code 3 or 4 -> The center considers all agents to be busy but continues to make requests to asterisk_receivedCall until the customer gets tired of waiting and abandons the call -> The center considers the call as canceled/abandoned and makes an API call to the asterisk_canceledCall method -> Movidesk automatically generates a ticket with a canceled call origin and generates an action in the ticket with the description of the call.
  • The center receives a phone call -> The center makes an API call to the asterisk_receivedCall method -> Movidesk returns the extension of the agent available to take the call -> The center verifies that the extension is not available (e.g., the agent originated a call, or the agent received an internal call, or the agent's phone is off the hook) -> The center makes another API call to the asterisk_receivedCall method until it receives a valid extension (happy scenario or alternative scenario 2) or considers the call as missed (alternative scenario 1) or canceled (alternative scenario 3).

 

Missed call

POST: https://api.movidesk.com/public/v1/asterisk_lostCall?
token=155cac97-f203-4bb8-86e1-aa4cb8781f3e&id=3&link=https://www.linkdagravacaodarecado.com.br&completedDate=2018-5-1T17:20:00

          Response: Status 200. This method should be called when the asterisk_receivedCall method returns codes 0, 1, and 2 or after several attempts when the asterisk_receivedCall method continues to return codes 3 and 4. In this case, a ticket with a missed call origin will be automatically generated, and an action with the respective information will be included in the ticket.

 

Cancelled/abandoned call

POST: https://api.movidesk.com/public/v1/asterisk_canceledCall?
token=155cac97-f203-4bb8-86e1-aa4cb8781f3e&id=3&canceledDate=2018-5-1T17:20:00

          Response: Status 200. This method should be called after the asterisk_receivedCall method and before the asterisk_transferedCall method, i.e., when the customer cancels/abandons the call before it is actually transferred to the agent. In this case, a ticket with a canceled call origin will be automatically generated, and an action with the respective information will be included in the ticket.


Example source code in C# for calling the API

Method POST

try
{

var response = await SendAsync("https://api.movidesk.com/public/v1/asterisk_receivedCall?
token=YOURTOKEN&queueId=1&clientNumber=4733990777&id=3&callDate=2018-5-1T17:00:00",
NULL, "POST", "application/json");

}
catch (WebException ex)
{
var response = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}

public static async Task<string> SendAsync(string uri, string content, string method, string contentType)
{
var req = WebRequest.Create(uri);
req.ContentType = contentType;
req.Method = method;

using (var stream = await req.GetRequestStreamAsync())
using (var streamWriter = new StreamWriter(stream))
{
await streamWriter.WriteAsync(content);
}

var httpResponse = (HttpWebResponse)await req.GetResponseAsync();
using (var stream = httpResponse.GetResponseStream())
{
if (stream == null)
return null;

using (var streamReader = new StreamReader(stream))
{
return await streamReader.ReadToEndAsync();
}
}
}

          The responses are detailed in the response variable and should be handled according to this documentation.