Muokkaa

Jaa


How to get estimated wait time and job position

In the context of a call center, customers might want to know how long they need to wait before they're connected to an agent. As such, Job Router can calculate the estimated wait time or position of a job in a queue.

Prerequisites

Get estimated wait time and length of a queue

Estimated wait time for a queue with is retrieved by calling GetQueueStatisticsAsync and checking the EstimatedWaitTimeMinutes property. The estimated wait time is grouped by job priority. Job Router also returns the length of the queue and the longest waiting job in the queue.

var queueStatistics = await client.GetQueueStatisticsAsync(queueId: "queue1");
Console.WriteLine($"Queue statistics: {JsonSerializer.Serialize(queueStatistics.Value)}");
var queueStatistics = await client.path("/routing/queues/{queueId}/statistics", "queue-1").get();
console.log(`Queue statistics: ${JSON.stringify(queueStatistics.body)}`);
queue_statistics = client.get_queue_statistics(queue_id = "queue1")
print("Queue statistics: " + queue_statistics)
RouterQueueStatistics queueStatistics = client.getQueueStatisticsWithResponse("queue1").getValue();
System.out.println("Queue statistics: " + BinaryData.fromObject(queueStatistics).toString());

Executing the above code should print a message similar to the following snippet (Note: the EstimatedWaitTimeMinutes property is grouped by job priority):

Queue statistics: { "QueueId":"queue1", "Length": 15, "EstimatedWaitTimeMinutes": { "1": 10 }, "LongestJobWaitTimeMinutes": 4.724 }

Get estimated wait time and position of a job in a queue

Estimated wait time for a job with ID job1 is retrieved by calling GetQueuePositionAsync and checking the EstimatedWaitTimeMinutes property. Job Router also returns the position of the job in the queue.

var queuePositionDetails = await client.GetQueuePositionAsync(jobId: "job1");
Console.WriteLine($"Queue position details: {JsonSerializer.Serialize(queuePositionDetails.Value)}");
var queuePositionDetails = await client.path("/routing/jobs/{jobId}/position", "job1").get();
console.log(`Queue position details: ${JSON.stringify(queuePositionDetails.body)}`);
queue_position_details = client.get_queue_position(job_id = "job1")
print("Queue position details: " + queue_position_details)
var queuePositionDetails = client.getQueuePosition("job1");
System.out.println("Queue position details: " + new GsonBuilder().toJson(queuePositionDetails));

Executing the above code should print a message similar to the following snippet:

Queue position details: { "JobId": "job1", "Position": 4, "QueueId": "queue1", "QueueLength":15, "EstimatedWaitTimeMinutes": 5 }