Queue Status
Via the Calls Widget embed instance we provide functionallity to help you to customize the experience for the shopper on your website for different queue status aspects around the Video Consultation service. That includes any custom logic that you may want to put on your web page around opening hours, available agents or estimated waiting time for queues.
The APIs described below are only available for the built-in Video Consultation queing system
Events
Each event is scoped for the current configured queue of the embed instance or fallback to the default queue set in the Bam Hub. Using the events is the recommended and easiest way to get this information. If you have the need to know the same information for multiple queues you can use the available methods instead.
queue-is-open
The queue-is-open
event is fired once when current time is within queue opening hours time span. In the workspace you can set the opening hours for queues and when not set a queue will be considered always opened.
Event properties
isOpen
- Flag indicating its open, alwaystrue
for this eventnextCloseTime
- Date and time when the queue is closing, may benull
when queues are always open
Example
embedInstance.on('queue-is-open', () => {
// Use the event for your own purposes, for example enable a button to open the Call Widget when queue is open
document.getElementById("call-widget-button").disabled = false
});
queue-is-closed
The queue-is-closed
event is fired once when current time is outside of queue opening hours time span. In the workspace you can set the opening hours for queues and if not set a queue will be considered always open and this event will never fire.
Event properties
isOpen
- Flag indicating its open, alwaysfalse
for this eventnextOpenTime
- Date and time when the queue is open again, may benull
when queues are always open
Example
embedInstance.on('queue-is-closed', () => {
// Use the event for your own purposes, for example disable a button to open the Call Widget when queue is closed
document.getElementById("call-widget-button").disabled = true
});
agents-online
The agents-online
event is fired everytime the number of online agents for the queue changes
Event properties
numberOfAgentsOnline
- Number of total online agents serving the current queuequeue
- The Bambuser Queue ID of current queue
Example
embedInstance.on('agents-online', ({ numberOfAgentsOnline }) => {
// Use the event for your own purposes, for example change some indicator text on your site
document.getElementById("status").text = numberOfAgentsOnline < 1 ? "Unfortunately there are no agents online" : "Let's have a video call!";
});
queue-estimated-waiting-time
The queue-estimated-waiting-time
event is fired everytime there is a change to the queue's estimated waiting time, number of shoppers in line or the number of online agents.
Event properties
estimatedWaitingTime
- Number of seconds that is currently estimated that shopper would need to stand in queue before beeing connected with an agentagents
- Number of total online agents serving the current queueplace
- Number of current waiting shoppers standing in line plus one, meaning the place the shopper would have after joining the queuequeue
- The Bambuser Queue ID of current queue
Example
embedInstance.on('queue-estimated-waiting-time', ({ estimatedWaitingTime }) => {
// Use the event for your own purposes, for example change some indicator text on your site
document.getElementById("waiting-time").text = `Estimated waiting time: ${estimatedWaitingTime}s`;
});
Methods
These methods will help determining the current queue status for other queues than the one embed instance has been configured with. If you are only interrested in the status for the current configured embed instance queue use the available events instead as they will fire automatically when changes happen.
areQueuesOpen()
Determine whether or not the queues are currently open. This method will hold cached values for a short period of time so trying to call it more often to get fresh data will not help.
Return value
A promise whose fulfillment handler will receive an object with properties:
isOpen
- Boolean flag indicating if queues are open or notnextOpenTime
- Date and time when the queue is open again, may benull
when queues are always opennextCloseTime
- Date and time when the queue is closing, may benull
when queues are always open
Example
const response = await embedInstance.areQueuesOpen();
// Use the response for your own purposes, for example disable a button if the queue is closed
if (!response.isOpen) {
document.getElementById("call-widget-button").disabled = true
}
getNumberOfOnlineAgents()
Determine how many agents that currently are online on a specific queue. This method will hold cached values for a short period of time so trying to call it more often to get fresh data will not help.
Parameters
queueTerm
- The name, slug or Bambuser Queue ID for the target queue. If omited the configured or default queue will be used.
Return value
A promise whose fulfillment handler will receive an object with properties:
numberOfAgentsOnline
- Number of total online agents serving the queuequeueId
- The resolved Bambuser Queue ID for the queue
Example usage:
const response = await embedInstance.getNumberOfOnlineAgents('awsome-queue');
// Use the response for your own purposes, for example change content on your site
if (response.numberOfAgentsOnline < 1) {
document.getElementById("bambuser-one-to-one-content").text = "Unfortunately there are no agents online"
};
The response will be in the shape of an object like this (with 123 agents being online in this example):
{
numberOfAgentsOnline: 123,
queueId: 'QUEUE_ID_HERE'
}
getEstimatedWaitingTime()
Determine the estimated waiting time for a specific queue, including the number of online agents and the calculated place shopper will have if entering the queue. This method will hold cached values for a short period of time so trying to call it more often to get fresh data will not help.
Parameters
queueTerm
- The name, slug or Bambuser Queue ID for the target queue. If omited the configured or default queue will be used.
Return value
A promise whose fulfillment handler will receive an object with properties:
estimatedWaitingTime
- Number of seconds that is currently estimated that shopper would need to stand in queue before beeing connected with an agentagents
- Number of total online agents serving the queueplace
- Number of current shoppers standing in line plus one, meaning the place the shopper would have after joining the queuequeueId
- The resolved Bambuser Queue ID for the queue
Example usage:
const response = await embedInstance.getEstimatedWaitingTime('awsome-queue');
// Use the event for your own purposes, for example change some indicator text on your site
document.getElementById("waiting-time").text = `Estimated waiting time: ${response.estimatedWaitingTime}s`;