Make a Call
In some cases, it is necessary for an agent to initiate a call to a phone number from another application, such as a CRM. This API can be used, and the call will be directed to the agent.
You can check the Colección de Postman to see an example and test it with your instance.
All data enclosed in {{ }} are values that will be replaced with the client's own data and/or the corresponding instance.
HTTP Request
Method | Resource |
POST | /Integra/resources/Agents/AgentCall |
Request Header
Opcion | Valor |
Content-Type | application/x-www-form-urlencoded |
Authorization | Basic {{Token}} |
Request Body
Parametro | Tipo |
Requerido | Descripción |
callerid | Número | Si | DID assigned to the campaign from which the call will be made. |
agent | Texto | Si | Agent who will take the call. |
phone
|
Número | Si | Agent's phone number. |
tech | Texto | Si | Communication protocol, add SIP. |
context | Texto | Si | Name of the context for flows from which the call will exit; it can be 'agentes' or 'agents.' |
outqueue | Texto | Si | Name of the manual campaign. |
destination | Número | Si |
Name of the campaign for which the call will be generated. |
Code Examples
You can copy the following code examples and replace the "{{variable}}" with the correct data.
HTTP
POST /Integra/resources/Agents/AgentCall HTTP/1.1
Host: {{instance}}.ucontactcloud.com
Authorization: Basic {{Token}}
Content-Type: application/x-www-form-urlencoded
Content-Length: 116
callerid={{callerid}}agent={{agent}}&phone={{phone}}&tech=SIP&context={{context}}&outqueue={{outqueue}}&destination={{destination}}
cURL
curl --location 'https://{{instance}}.ucontactcloud.com/Integra/resources/Agents/AgentCall' \
--header 'Authorization: Basic {{Token}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'callerid={{callerid}}' \
--data-urlencode 'agent={{agent}}' \
--data-urlencode 'phone={{phone}}' \
--data-urlencode 'tech=SIP' \
--data-urlencode 'context={{context}}' \
--data-urlencode 'outqueue={{outqueue}}' \
--data-urlencode 'destination={{destination}}'
JavaScript
const myHeaders = new Headers();
myHeaders.append("Authorization", "Basic {{Token}}");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
const urlencoded = new URLSearchParams();
urlencoded.append("callerid", "{{callerid}}");
urlencoded.append("agent", "{{agent}}");
urlencoded.append("phone", "{{phone}}");
urlencoded.append("tech", "SIP");
urlencoded.append("context", "{{context}}");
urlencoded.append("outqueue", "{{outqueue}}");
urlencoded.append("destination", "{{destination}}");
const requestOptions = {
method: "POST",
headers: myHeaders,
body: urlencoded,
redirect: "follow"
};
fetch("https://{{instance}}.ucontactcloud.com/Integra/resources/Agents/AgentCall", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
JQuery
var settings = {
"url": "https://{{instance}}.ucontactcloud.com/Integra/resources/Agents/AgentCall",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "Basic {{Token}}",
"Content-Type": "application/x-www-form-urlencoded"
},
"data": {
"callerid": "{{callerid}}",
"agent": "{{agent}}",
"phone": "{{phone}}",
"tech": "SIP",
"context": "{{context}}",
"outqueue": "{{outqueue}}",
"destination": "{{destination}}"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
C#
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://{{instance}}.ucontactcloud.com/Integra/resources/Agents/AgentCall");
request.Headers.Add("Authorization", "Basic {{Token}}");
var collection = new List<KeyValuePair<string, string>>();
collection.Add(new("callerid", "{{callerid}}"));
collection.Add(new("agent", "{{agent}}"));
collection.Add(new("phone", "{{phone}}"));
collection.Add(new("tech", "SIP"));
collection.Add(new("context", "{{context}}"));
collection.Add(new("outqueue", "{{outqueue}}"));
collection.Add(new("destination", "{{destination}}"));
var content = new FormUrlEncodedContent(collection);
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Java
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "callerid={{callerid}}&agent={{agent}}&phone={{phone}}&tech=SIP&context={{context}}&outqueue={{outqueue}}&destination={{destination}}");
Request request = new Request.Builder()
.url("https://{{instance}}.ucontactcloud.com/Integra/resources/Agents/AgentCall")
.method("POST", body)
.addHeader("Authorization", "Basic {{Token}}")
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
Python
import http.client
conn = http.client.HTTPSConnection("{{instance}}.ucontactcloud.com")
payload = 'callerid={{callerid}}&agent={{agent}}&phone={{phone}}&tech=SIP&context={{context}}&outqueue={{outqueue}}&destination={{destination}}'
headers = {
'Authorization': 'Basic {{Token}}',
'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "/Integra/resources/Agents/AgentCall", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
HTTP Response
Responses in which an error occurred due to the data sent will generally be returned with an HTTP code 200 and a '0' in the response body; therefore, caution should be exercised when validating by the HTTP Code Response.
The successful response will be a GUID as the call identifier; this data can be used for future actions through APIs.
Successful response.
8cf8570e-60e7-44ed-b799-3baab211b04d
Error response.
0