Question
Coforge
IN
Last activity: 9 Mar 2022 11:03 EST
Reset Chat Interaction and start New Interaction
Hi All,
We have a requirement where close icon will be provided in chat bot header, on click close icon the current chat interaction should be resolved and the bot window to be minimized. Again when we click on chat bubble a new interaction to be started with fresh conversation. We are showing Chatbot in website using Mashup. We tried to use the same logic used on reset link provided in console, but the chat bot finally rendered in website there this reset logic was not working as expected on browser refresh again the conversation history and some work object is loaded.
Any inputs to fulfill above requirement.
Thanks, Srinivas S
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
IN
@SSrinivas Preview console is different than chatbot deployed on an external site. Same functionality will not work.
What you will need to do is send a call to 'Close all interactions' when someone clicks on Close icon.
@Piotr Kulig any idea how to address this scenario.
Updated: 15 Jul 2021 8:11 EDT
Coforge
IN
@VikasRaidhan Thanks Vikas for inputs. I did the same resolving all interactions and clearing Session variables like BotStarted and AssignmentKey. But again when we click on chat bubble there is no new case creation happens and on refresh of Browser I see the old interaction gets loaded with Session values as well.
Thanks
Pegasystems Inc.
US
@SSrinivasIf you want to override the minimize button to completely clear the session, you will need to do some additional work. The key step will be to invoke the logoff action like shown below. Typically the minimize action will throw a postmessage to the desktop, which will process the action. You can use same action and update the minimizeAdvisor function to do the few other actions shown below.
function resetBot(){
pega.web.api.doAction("OnlineHelp", "logoff");
/* Following lines may be needed depending on the version */
sessionStorage.removeItem("BotStarted");
sessionStorage.removeItem("AssignmentKey");
}
Coforge
IN
@Amit_Patel Thanks for reply, I have tried by defining the give code snippet and calling the JS function on click but still no luck. Bot is getting minimized but the session is not getting cleared.
Can you please help.
Thanks
Pegasystems Inc.
US
@SSrinivas Hello, in order to customize this, you will need to do the following:
The section Work-Channel-Chat.GuideHeader has the minimize icon included in Dynamic Layout 1.2. This has some actions configured on it. It calls a DT called SetupMinimizeCommand, which puts a JSON string into .MashupRequestDataJSON property. This payload is "{\"command\":\"minimizeFromAdvisor\"}". This is followed by a call to parent.PostMessage of that payload. If you want to use the same icon to trigger the reset, then no changes are needed here.
The second part of this is in the PegaHelper.JS File. When that message is sent from mashup to the parent page, the function minimizeAdvisor is invoked. Currently, that function uses CSS to hide the mashup and show the restore button. It also sets some sessionStorage properties. In your case, you would REPLACE the content of that function with resetBot code I sent above. Put a debugger statement in this function to ensure that it's getting called. Once the LogOff action is called and the session variables are cleared, you can call the displayLauncher() function to show the launcher icon again.
This might take some tweaking to get the behavior correct, especially in terms of hiding the mashup and showing the correct launcher button.
Amit
Coforge
IN
@Amit_Patel Hello Amit, I have tried this in below ways.
1.Introducing new Icon CLOSE (X) which has just resetBot function call on click and no changes done to minimizeAdvisor.
2.Adding resetBot snippet in minimizeAdvisor function. please find the changes we have did for minimizeAdvisor function.
function minimizeAdvisor(message) {
hideElement("launcher");
removeCSSClass("OnlineHelp", "alerting");
showElement("launcherminimized");
hideElement("unreadCounter");
minimized = true;
missedMessageCounter = 0;
sessionStorage.setItem("botMinimized", true);
sessionStorage.setItem("unreadCount", 0);
sessionStorage.removeItem("BotStarted");
sessionStorage.removeItem("AssignmentKey");
sessionStorage.removeItem("ConversationID");
pega.web.api.doAction("OnlineHelp", "logoff");
console.log("Done");
displayLauncher();
console.log("launched");
}
#2 outcome : Launcher getting Minimized, but after clicking on launcher bubble the window is not getting opened, I have ended up with browser refresh and clicking the bubble then I see all the previous conversation still there, not sure did I missed anything in this. We have raised Incident for this INC-187921, is it possible for you to connect as part of this INC in webex to check further ?
Thanks, Srinivas S
Pegasystems Inc.
US
@SSrinivasHi, Option 1 will not work as I'm sure you already found out. For option 2, I just tried the following code and it worked.
function minimizeAdvisor(message) {
hideElement("launcher");
removeCSSClass("OnlineHelp", "alerting");
hideElement("unreadCounter");
sessionStorage.removeItem("BotStarted");
sessionStorage.removeItem("AssignmentKey");
sessionStorage.removeItem("ConversationID");
pega.web.api.doAction("OnlineHelp", "logoff");
console.log("Done");
showElement("launcher");
console.log("launched");
}
can you try that out?
Coforge
IN
@Amit_Patel Hi Amit,
I have tried with your code still not working, can you please let me know which version you tried.
FYI, the question was posted 8 months back during that time we were on 8.5.3, now we are in 8.6.2 (platform) and CS (8.6.1) and I'm doing testing on our current version only.
Thanks, Srinivas S
Pegasystems Inc.
US
@Sreedevi9193 I tried this on the 8.5 version. For some reason, our 8.6 hotfix server is having some issues and it's not running the bot at all. That might take a bit to fix.
Did you put a breakpoint in this function when you are minimizing the Bot to ensure that it's running when you hit the minimize button?
Coforge
IN
Hello Amit,
Yes, we have kept breakpoints and console logs, I see this function getting executed and the console.logs also getting printed in console tab.
Thanks,
Srinivas S
Pegasystems Inc.
US
@SSrinivas What exactly is happening after you see those functions execute and logs print out?