Taskrouter worker activity not changed when websocket disconnects

527 Views Asked by At

I'm using twiliotaskrouter13.min.js to initiate a worker using

    this.workerClient = new Twilio.TaskRouter.Worker(
      token,
      this.twilioConfig.debugging,
      this.twilioConfig.workerActivities.offline,
      this.twilioConfig.workerActivities.offline,
      true
    );

The expected behaviour is that when the websocket gets dropped, the agent is automatically moved to "Offline" state

Adding Connecting and Disconnecting Activities, and closing Existing >Sessions

var worker = new Twilio.TaskRouter.Worker(WORKER_TOKEN, false, "WAxxx", "WAyyy", true);

https://www.twilio.com/docs/taskrouter/js-sdk/worker#taskrouterworker

However, it seems that this is not the current behaviour, I tested with several workers and it looks like the worker remains in the current state after the websocket gets disconnected.

Does anybody know if we're missing something? Maybe a different config or a timeout somewhere?

1

There are 1 best solutions below

1
On

I ran into the same problem a while back, sent a message to support, and got this answer:

When you try to update a worker to Offline, as the worker.js is doing, it will fail if the worker has a reservation.

The only thing I can think of doing is adding a custom "unload" event handler to your app's client-side code so that it will reject any pending reservations before setting the worker offline.

The documentation lacks some details on how the disconnecActivitySid works. I ended up adding a unload event listener to the page and also modified the webhook to update the worker's activity to Away when the worker misses 10 reservations in a row.

The task assignment callback can return an instruction to reject the task and an unavailable activity so that the worker stops receiving new tasks. For instance, { instruction: 'reject', activity_sid: '<away_activity_sid' }.