Twilio Flex Actions Framework (WrapupTask or beforeWrapupTask) event - example not working

Viewed 62

Based on the Twilio documentation examples, Actions Framework, I am not having much luck with capturing events for WrapupTask or beforeWrapupTask, it appears the events just never fire and I am not clear on how to go about troubleshooting this?

The code examples I've tired (even identical examples from the documentation) using the latest version of Twilio Flex and the --flexui2 deployment of the Twilio Flex plugin (@twilio-labs/plugin-flex 5.1.2) that don't fire are:

Actions.addListener("beforeWrapupTask", (payload) => {
   console.log(`***Task Channel Unique Name: ${payload.task.taskChannelUniqueName}`);
   alert("Fired - beforeWrapupTask")
})

or

Actions.addListener("WrapupTask", (payload) => {
   console.log(`***Task Channel Unique Name: ${payload.task.taskChannelUniqueName}`);
   alert("Fired - WrapupTask")
})

and no luck either with this approach (with many different variations of) - actually the below approach seemed to introduce issues with other events firing like afterAcceptTask for some unknown reason.

    flex.Actions.replaceAction("WrapupTask", (payload, original) => {
        return new Promise(function(resolve, reject) {
          // Send the message:
          console.log('***** THIS EVENT FIRED!!!! *****')
          }).then(response => {
            // Wait until the message is sent to wrap-up the task:
            resolve(original(payload));
        });
      });

Any reason the examples don't work? Has anything changed? I can get beforeCompleteTask working but I really need beforeWrapupTask.

I've exhausted all attempts at finding any information in the documentation or other sources.

Thanks!

1 Answers

So for Voice tasks, it works differently from feedback I received back from a Twilio support ticket. You would take the approach below.

//start listening on reservation created
manager.workerClient.on("reservationCreated", (reservation) => {

//trigger code when wrap-up starts
 reservation.on("wrapup", (reservation) => {
   alert("End Media Capture - WrapupTask")
 });
}); 
Related