Danamon Enhancement WEB Development Guide - Queue Position and Estimated Wait Time
Queue
Fully Positionimplemented andjavascript Estimatedcode Waitexample Timeis in the WaitForAgent.html
The frontend application can show the caller's queue position and estimated wait time while the caller is waiting for an agent.
This flow does not require a mobile SDK. The frontend application calls the ECV Web.App HTTP endpoint and updates its own waiting screen.
1. Previous Flow
Previously, the frontend called:
GET https://your-ecv-service/service/api/WaitForRoomInterval?rtcId={rtcId}
The response contained only the waiting state:
"wait"
or:
"agent_connected"
Because the response did not include queue information, the frontend could only keep showing the waiting screen until the agent connected.
2. New Endpoint
The frontend should now call:
GET https://your-ecv-service/service/api/WaitForRoomQueueInterval?rtcId={rtcId}
This endpoint keeps the previous state behavior and additionally returns queue position and estimated wait time.
3. Request
GET https://your-ecv-service/service/api/WaitForRoomQueueInterval?rtcId={rtcId}
| Parameter | Type | Required | Description |
|---|---|---|---|
rtcId |
string | Yes | The ECV room id returned by DialEx. |
4. Responses
4.1 Caller is waiting in queue
{
"State": "wait",
"Position": 3,
"Ewt": 45.2
}
| Field | Description |
|---|---|
State |
Current waiting state. |
Position |
Current queue position of the caller. |
Ewt |
Estimated wait time in seconds. |
The frontend should keep the waiting screen open and display the queue information.
4.2 Agent is ready / call is connecting
{
"State": "wait",
"Position": -1,
"Ewt": -1
}
Position = -1 and Ewt = -1 means the caller is no longer waiting in the queue. The agent is ready and the call is moving to connection.
The frontend should hide queue numbers and continue waiting for the final agent_connected state.
4.3 Agent connected
{
"State": "agent_connected",
"Position": null,
"Ewt": null
}
When State is agent_connected, the frontend should open the ECV video room.
var roomUrl = "https://your-ecv-service/r/"
+ encodeURIComponent(roomId)
+ "?user=" + encodeURIComponent(customerName)
+ "&site=2&im=true&device=Int&version=2";
4.4 Missing rtcId
400 Bad Request
rtcId is required.
5. Example Frontend Implementation
<div id="queueInfo" hidden>
<span id="queuePosition"></span>
<span id="queueEwt"></span>
</div>
async function waitForAgent(roomId) {
var url = "https://your-ecv-service/service/api/WaitForRoomQueueInterval?rtcId="
+ encodeURIComponent(roomId);
var response = await fetch(url);
var data = await response.json();
if (data.State === "wait") {
updateQueueInfo(data.Position, data.Ewt);
return;
}
if (data.State === "agent_connected") {
openVideoRoom(roomId);
return;
}
console.error("Unexpected WaitForRoomQueueInterval response", data);
}
function updateQueueInfo(position, ewt) {
var queueInfo = document.getElementById("queueInfo");
if (position == null || position < 0) {
queueInfo.hidden = true;
return;
}
document.getElementById("queuePosition").textContent = "Queue: " + position;
document.getElementById("queueEwt").textContent =
ewt != null && ewt >= 0 ? " | EWT: " + Math.round(ewt) + " sec" : "";
queueInfo.hidden = false;
}
6. Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Queue numbers do not appear | Frontend is still calling WaitForRoomInterval |
Use WaitForRoomQueueInterval |
Queue values are -1 / -1 |
Caller is no longer in queue; agent is ready or call is connecting | Hide queue numbers and continue waiting for agent_connected |
Queue values are null / null |
Queue information is unavailable or call has ended | Hide queue numbers; optionally stop polling based on customer flow |
400 Bad Request |
rtcId was not sent |
Send the room id returned by DialEx |