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}); } });
Fires:
- Worker#event:activityUpdated
- Worker#event:attributesUpdated
- Worker#event:disconnected
- Worker#event:error
- Worker#event:ready
- Worker#event:reservationCreated
- Worker#event:tokenExpired
- Worker#event:tokenUpdated
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 }