Trigger an event from Toaster popup - GWS API

Hi,

I’m trying to customize the toaster popup in WWE with custom buttons. I’m able to replace the “Show/Dismiss” buttons to “Yes/No”. Now I need to execute functionality when agents click “Yes” or “No”. The document shows not much info or I’m looking at the wrong doc.

Can someone please help with this question?

Here is my code.

const buttonName = [“Yes”, “No”];
genesys.wwe.service.system.popupToast({
title: “Alert Message”,
iconUrl: msgURL,
subject: “Testing”,
message: “Click Yes/No”,
buttons: buttonName,
buttonShowDismiss: false
}, succeeded, failed);

Thanks,
Kumar

have you tried subscribing to “system” notifications and validating the message object if the event.data.eventType property is “CUSTOM_TOAST_BUTTON_CLICK” and then getting event.data.buttonIndex = 0 (Yes) or 1 (No)?

Also, you probably should assign the result of your popupToast method call to a variable so you can compare against event.data.customToastId when performing the event handling.

Check if the “Notifications” chapter of the following link helps:
https://docs.genesys.com/Documentation/HTCC/9.0.0/Dev/ServiceClientAPI

roughly, I believe that could be something like this:


const buttonName = ["Yes", "No"];
var myCustomToastId;

// Event Handler for system notifications
function myEventHandler(message)
{
    if (!message.hasOwnProperty("event")) return; // Missing property "event" on notification event
    if (!message.hasOwnProperty("data")) return;  // Missing property "data" on notification event
    if (!message.data.hasOwnProperty("eventType")) return; // Missing property "data.eventType" on notification event

    // Using switch clause in case you want to add a handler for other events
    switch(message.data.eventType) {
        case "CUSTOM_TOAST_BUTTON_CLICK":
            if (!message.data.hasOwnProperty("customToastId")) return;
            if (message.data.customToastId !== myCustomToastId) return; // These aren't the toasts you are looking for
            alert("I clicked on " + buttonName[message.data.buttonIndex] + " button!!!"); // Show an alert saying which button you clicked on
            break;
    }
}

// Subscribe for system events here
genesys.wwe.service.subscribe([ "system" ], myEventHandler, this);

// Add a reference id for your toast so you can compare later
myCustomToastId = genesys.wwe.service.system.popupToast({
                        title: "Alert Message",
                        iconUrl: msgURL,
                        subject: "Testing",
                        message: "Click Yes/No",
                        buttons: buttonName,
                        buttonShowDismiss: false
                    }); // I removed the callbacks. I don't think they are present on popupToast method call


Thanks hsujdik,

It worked perfectly.

I have another question. Is it possible to wordwrap (display messages on 2 lines) message.

const buttonName = [“Yes”, “No”];
genesys.wwe.service.system.popupToast({
title: “Alert Message”,
iconUrl: msgURL,
subject: “Testing”,
message: “Click Yes/No”,
buttons: buttonName,
buttonShowDismiss: false
}, succeeded, failed);

Thanks,
Kumar

Hi, Kumar.

That I don’t know. Try something like this to see if it works:

message: “Click \nYes/No”

or

message: “Click
Yes/No”

Regards,
H. Sujdik

Hi Sujdik,

Thanks for the response.
I actually reading message text from CME so \n is considered as text and displayed like “Click \nYes/No”. Tried
, displayed “Click Yes/No” like this but no line break. Also tried some custom CSS but not helped

Finally, tried with   - it worked (  we use this one also).

Thanks,
Kumar