0

I'm attempting to build a contact center where text and voice calls are routed to workers by taskrouter.js. The text side of this is working but I am struggling to figure out how a worker is to accept a call that has been enqueued as a task. I've tried the following in my flex.js

workerClient.on("reservation.accepted",
function (reservation) {
    showLoader();
    // update worker status to busy
    UpdateWorkerStatus("Unavailable").catch((e) => {
        console.error('Error setting status to busy:', e.code, e.message);
    });

    if (reservation.task.taskChannelUniqueName === "chat") {
        // if chat then add agent to conversation and pop the window
        AddAgent(reservation.task.attributes.conversationSid).then((conversation) => {
            // after adding the agent, pop a new window and connect the client
            //PopChatWindow();

            LoadCustomerCenter(reservation);
        });
    } else {
        // in the event of a voice call
        console.log("time to dequeue ");
        reservation.conference();
        LoadCustomerCenter(reservation);
    }
});

But am confronted with the error Unable to execute Conference instruction. Reservation is not currently in a Pending state.

I've also replaced the reservation.conference() with reservation.dequeue() but am confronted with Dequeue instruction can only be executed on a currently pending reservation.

Clearly, I'm not understanding the process involved. I figure there must be documentation on this but it seems to stop short of how to answer calls once they are enqueued.

neanderslob
  • 2,633
  • 6
  • 40
  • 82

0 Answers0