Widget v2 - Cancel or Close Widget notification

Hello Community,
As part of a Chat v2 deployment for a customer, we need to be able to get notified if / when the user clicks the Cancel or the Close (X) button before having started a Chat session.
I could not find anything to achieve that on this Genesys page:
https://all.docs.genesys.com/WID/Current/SDK/WebChatService-combined#API_events.
I also tried to use jquery statements to get notified, but so far this does not work. I guess it's linked to the fact that the objects are not part of the DOM when the page first loads.

Any hint / help welcome !
Thanks

Hello,

You could use the WebChat.Closed event. It will be raised when the chat window is closed.
This can happen in 2 scenarios:

  • The chat was started/connected and it was terminated (by an agent, by the customer after interacting with an agent, by the customer while waiting in the queue or interacting with a bot).
  • The chat registration was opened and closed by the customer without starting the chat.

You can analyze the metadata provided in the WebChat.closed event and distinguish the 2 scenarios (as shown below).
When you configure the widget (javascript/html - client side), you can set the following:

window._genesys.widgets.onReady = function (QuickBus) {

    localWidgetPlugin = CXBus.registerPlugin('CustomChatPlugin');

    localWidgetPlugin.subscribe("WebChat.closed", function (e) {
        if (e.data.started != false) {
            console.log('CHAT WAS ACTIVE AND WAS CLOSED - CHAT WAS STARTED AND ENDED');
        } else {
            console.log('CHAT WAS CLOSED BEFORE BEING STARTED - CHAT WAS NEVER STARTED BY THE CUSTOMER');
        }
    });

};

Regards,

Thanks Jerome !
This is exactly what I was looking for.
I was trying with events like: localWidgetPlugin.subscribe("WebChatService.ended", ...)
which do not trigger in that case.

Thanks again, have a good day

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.