V 2.0

Live Queue

Description

The Live Queue API provides real-time information and control over the call queue system. It allows users to monitor queue statistics, agent statuses, and perform actions such as call barging. This API is crucial for call center managers and supervisors to maintain efficient operations and ensure optimal customer service.

Key features of the Live Queue API include:

  1. Real-time queue statistics

  2. Agent status monitoring

  3. Call barging capabilities

  4. Flexible data filtering and aggregation

The API uses Elasticsearch for quick data retrieval and RabbitMQ for real-time message passing, ensuring high performance and scalability.

Authentication

All endpoints require authentication using either an SSID or a combination of userId and token. Ensure that you provide the necessary authentication parameters with each request.

Error Codes

The following error codes are specific to the Live Queue API:

Error Code Description
1501 Data already in processing
1502 Invalid filter value

For more general error codes, please refer to the main SarvErrors documentation.

Error Responses

Error responses will have the following format:

{
  "status": "error",
  "message": "Error message",
  "code": 1502
}

Rate Limiting

There are currently no specific rate limits for these endpoints. However, please use them responsibly to avoid overloading the server.

count

{{brand}}/api/v2/liveQueue/count

Endpoint

Description

This endpoint retrieves real-time queue and agent performance metrics for a call center environment. It allows users to fetch detailed analytics with flexible filtering, aggregation, and data selection options.

Key Features:

Request Parameters

Parameter Type Required Description Default
ssid string Conditional Session ID for authentication -
userId string Conditional User ID for authentication -
token string Conditional Token for authentication -
filter array Optional Array of filter objects to narrow down the data -
extra array Optional Additional custom parameters -
breakDown string Optional Field to break down the data "agentId"
disPlay string Optional Field to display "date"
fields array Optional Array of fields to retrieve ["TC"]
multi boolean Optional Enable multi-field aggregation false

Extra Parameters

Key Value Type Description Example Value
includeInactive string Include data for inactive agents or queues "true"
timeZone string Specify a time zone for the returned data "UTC+5:30"
groupBy string Group the data by a specific interval "hourly"

Fields Parameter Values

Field Description
TC Total Calls
AC Active Calls
WT Wait Time
AT Average Time
AHT Average Handle Time
ABT Average Break Time

Response Breakdown Table

Key Value Description
onB 5 Number of agents currently on break
onC 10 Number of agents currently on a call
web 20 Number of agents logged in via web interface
agTc 30 Total number of agents
size 100 Current size of the queue
grp ["Sales", "Support"] Agent groups/departments
ag ["Agent1", "Agent2", "Agent3"] List of individual agents
st ["Available", "On Call", "After Call Work"] Agent status types
str {"Round Robin": 50, "Least Recent": 30} Call distribution strategies and their percentages
ctyp {"Inbound": 60, "Outbound": 40} Call types and their distribution
campId ["Summer_Sale", "Customer_Feedback"] Campaign IDs
qDura ["0-30", "31-60", "61+"] Queue duration categories
did ["1800123456", "1800789012"] Dial/contact numbers
TC 150 Total Calls
AC 25 Active Calls
WT 120 Wait Time
AHT 180 Average Handle Time

Authentication Notes

Additional Details

This table provides a comprehensive overview of all the parameters available in the Get Queue Count endpoint, making it easier to understand and utilize the API effectively.

count

var axios = require('axios');
var data = '{"ssid":"{{ssid}}"}';

var config = {
 method: 'post',
 url: '{{brand}}/api/v2/liveQueue/count',
 headers: { 
'Content-Length': ''
 },
 data : data
};

axios(config)
.then(function (response) {
 console.log(JSON.stringify(response.data));
})
.catch(function (error) {
 console.log(error);
});
setUrl('{{brand}}/api/v2/liveQueue/count');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
 'follow_redirects' => TRUE
));
$request->setHeader(array(
 'Content-Length' => ''
));
$request->setBody('{"ssid":"{{ssid}}"}');
try {
 $response = $request->send();
 if ($response->getStatus() == 200) {
echo $response->getBody();
 }
 else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
 }
}
catch(HTTP_Request2_Exception $e) {
 echo 'Error: ' . $e->getMessage();
}
import http.client

conn = http.client.HTTPSConnection("{{brand}}")
payload = "{\"ssid\":\"{{ssid}}\"}"
headers = {
 'Content-Length': ''
}
conn.request("POST", "/api/v2/liveQueue/count", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var client = new RestClient("{{brand}}/api/v2/liveQueue/count");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var body = @"{" + "\n" +
@"    ""ssid"":""{{ssid}}""" + "\n" +
@"}";
request.AddParameter("text/plain", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
curl --location -g --request POST '{{brand}}/api/v2/liveQueue/count' \
--data-raw '{
    "ssid":"{{ssid}}"
}'
var request = http.Request('POST', Uri.parse('{{brand}}/api/v2/liveQueue/count'));
request.body = '''{\n    "ssid":"{{ssid}}"\n}''';

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
   print(await response.stream.bytesToString());
}
else {
   print(response.reasonPhrase);
}
package main

import (
   "fmt"
   "strings"
   "net/http"
   "io/ioutil"
)

func main() {

   url := "%7B%7Bbrand%7D%7D/api/v2/liveQueue/count"
   method := "POST"

   payload := strings.NewReader(`{
    "ssid":"{{ssid}}"
}`)

   client := &http.Client {
   }
   req, err := http.NewRequest(method, url, payload)

   if err != nil {
      fmt.Println(err)
      return
   }
   res, err := client.Do(req)
   if err != nil {
      fmt.Println(err)
      return
   }
   defer res.Body.Close()

   body, err := ioutil.ReadAll(res.Body)
   if err != nil {
      fmt.Println(err)
      return
   }
   fmt.Println(string(body))
}
POST /api/v2/liveQueue/count HTTP/1.1
Host: {{brand}}
Content-Length: 25

{
    "ssid":"{{ssid}}"
}
OkHttpClient client = new OkHttpClient().newBuilder()
   .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n    \"ssid\":\"{{ssid}}\"\n}");
Request request = new Request.Builder()
   .url("{{brand}}/api/v2/liveQueue/count")
   .method("POST", body)
   .addHeader("Content-Length", "")
   .build();
Response response = client.newCall(request).execute();
var myHeaders = new Headers();
myHeaders.append("Content-Length", "");

var raw = "{\n    \"ssid\":\"{{ssid}}\"\n}";

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("{{brand}}/api/v2/liveQueue/count", requestOptions)
   .then(response => response.text())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
   curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
   curl_easy_setopt(curl, CURLOPT_URL, "%7B%7Bbrand%7D%7D/api/v2/liveQueue/count");
   curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
   struct curl_slist *headers = NULL;
   headers = curl_slist_append(headers, "Content-Length: ");
   curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
   const char *data = "{\n    \"ssid\":\"{{ssid}}\"\n}";
   curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
   res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
#import 

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"%7B%7Bbrand%7D%7D/api/v2/liveQueue/count"]
   cachePolicy:NSURLRequestUseProtocolCachePolicy
   timeoutInterval:10.0];
NSDictionary *headers = @{
   @"Content-Length": @""
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n    \"ssid\":\"{{ssid}}\"\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
   if (error) {
      NSLog(@"%@", error);
      dispatch_semaphore_signal(sema);
   } else {
      NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
      NSError *parseError = nil;
      NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
      NSLog(@"%@",responseDictionary);
      dispatch_semaphore_signal(sema);
   }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix

let postData = ref "{\n    \"ssid\":\"{{ssid}}\"\n}";;

let reqBody = 
   let uri = Uri.of_string "%7B%7Bbrand%7D%7D/api/v2/liveQueue/count" in
   let headers = Header.init ()
      |> fun h -> Header.add h "Content-Length" ""
   in
   let body = Cohttp_lwt.Body.of_string !postData in

   Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
   body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
   let respBody = Lwt_main.run reqBody in
   print_endline (respBody)
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Length", "")

$body = "{`n    `"ssid`":`"{{ssid}}`"`n}"

$response = Invoke-RestMethod '{{brand}}/api/v2/liveQueue/count' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "net/http"

url = URI("{{brand}}/api/v2/liveQueue/count")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Length"] = ""
request.body = "{\n    \"ssid\":\"{{ssid}}\"\n}"

response = http.request(request)
puts response.read_body
printf '{
    "ssid":"{{ssid}}"
}'| http  --follow --timeout 3600 POST '{{brand}}/api/v2/liveQueue/count' \
 Content-Length:
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let parameters = "{\n    \"ssid\":\"{{ssid}}\"\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "{{brand}}/api/v2/liveQueue/count")!,timeoutInterval: Double.infinity)
request.addValue("", forHTTPHeaderField: "Content-Length")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
   guard let data = data else {
      print(String(describing: error))
      semaphore.signal()
      return
   }
   print(String(data: data, encoding: .utf8)!)
   semaphore.signal()
}

task.resume()
semaphore.wait()

Example Response

 [{"key":"Date"
"value":"Fri
 29 Nov 2024 04:16:15 GMT"}
{"key":"Content-Type"
"value":"application\/json; charset=utf-8"}
{"key":"Content-Length"
"value":"159"}
{"key":"Connection"
"value":"keep-alive"}
{"key":"Access-Control-Allow-Origin"
"value":"*"}
{"key":"Access-Control-Allow-Methods"
"value":"POST
 GET
 OPTIONS
 PATCH
 DELETE"}
{"key":"Access-Control-Allow-Headers"
"value":"X-Requested-With
content-type"}
{"key":"Access-Control-Allow-Credentials"
"value":"true"}
{"key":"Vary"
"value":"Origin"}
{"key":"ETag"
"value":"W\/\"9f-5CvV3aU8QdyXuu8UyL7A+65\/6As\""}
{"key":"Strict-Transport-Security"
"value":"max-age=31536000; includeSubDomains"}]
 {
    "data": {
        "onB": 0,
        "onC": 0,
        "web": 2,
        "agTc": 13,
        "size": 0,
        "grp": [],
        "ag": [],
        "st": [],
        "str": {},
        "ctyp": {},
        "campId": [],
        "qDura": [],
        "did": []
    },
    "status": "success",
    "code": 200
}