Twilio Flex Manager

Documentation: https://www.twilio.com/docs/flex/developer/ui/manager

On Connect

Flex.Manager.getInstance().voiceClient.on('connect', () => {
  console.log('connect');
});

Action inside reservation

Flex.Manager.getInstance().workerClient.on("reservationCreated", reservation => {
  if (reservation.task.taskChannelUniqueName === 'chat' && reservation.task.direction === 'inbound') {
    Flex.Actions.invokeAction("AcceptTask", {sid: reservation.sid});
    Flex.Actions.invokeAction("SelectTask", {sid: reservation.sid});
  }
});

WorkerClient documentation

Fires:

Get task within manager instance

 const state = manager.store.getState();
 const workerTasks = state.flex.worker.tasks;
 const taskIterator = workerTasks.entries();
    
 for (const reservationEvent of taskIterator) {
      //list task here
 }