I am trying to configure toast pop up notification, similar to what is described here: Once agent finishes web message, send to a bot flow
I am able to deploy the toast notification without any problems but I am struggling to re-initiate the message session. I want to be able to re-initialise the web message chat after the agent disconnects so I can send the customer back into the flow to complete a survey.
I've been looking at the following article but can't figure out the right combination of commands to re-initialise: https://developer.genesys.cloud/commdigital/digital/webmessaging/messengersdk/SDKCommandsEvents/messagingServicePlugin#messagingservice-sendmessage
I can re-initiate session by using "MessagingService.sendMessage" or "MessagingService.resetConversation" but is this the correct way to do this?
I've tried a lot of the other commands but they don't appear to start the conversation again. Instead the customer is presented with option to "Start new" button.
Here is the example of my code:
(function (g, e, n, es, ys) {
g['_genesysJs'] = e;
g[e] = g[e] || function () {
(g[e].q = g[e].q || []).push(arguments)
};
g[e].t = 1 * new Date();
g[e].c = es;
ys = document.createElement('script'); ys.async = 1; ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.mypurecloud.ie/genesys-bootstrap/genesys.min.js', {
environment: 'euw1',
deploymentId: 'XXXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
});
Genesys("subscribe", "MessagingService.conversationDisconnected", function({data}){
console.log(data);
Genesys("command", "Database.get", { name: "messaging.customAttributes.surveyOptIn" },
function(data){
console.log("Survey Offered Already");
},
function(){
Genesys("subscribe", "Toaster.ready", () => {
Genesys("command","Toaster.open",
{
title: "Would you like to take part in a survey?",
body: "In order to improve our services we'd like to ask you a quick 5 question survey.",
buttons: {
type: "binary", // required when 'buttons' is present. Values: "unary" for one action button, "binary" for two action buttons
primary: "Yes", // optional, default value is "Accept"
secondary: "No", // optional, default value is "Decline"
},
},
function () {
/*fulfilled callback*/
console.log("Toaster is opened");
},
function (error) {
/*rejected callback*/
console.log("There was an error running the Toaster.open command:", error);
}
);
});
}
);
});
Genesys("subscribe","Toaster.accepted",
function (e) {
console.log("Toaster was accepted", e);
Genesys("command", "Database.set", { messaging: { customAttributes: { surveyOptIn: 'true' }}},
function(data){ /* fulfilled, returns data */}, function(){ /* rejected */ });
// Re-initiate the conversation at this point? What commend is required?
Genesys("command", "Messenger.openConversation");
}
);
Genesys("subscribe","Toaster.declined",
function (e) {
console.log("Toaster was declined", e);
}
);
Thanks,
Darren