Question
6
Replies
75
Views
Posted: June 29, 2020
Last activity: July 13, 2020
Attempts to load the chat widget on-demand
we have a requirement to load the chat widget on-demand. this is required as user identifier is loaded asynchronously. so we need to load the chat widget only after customer data available in website.
we have modified idex.html to load the widget.
<!DOCTYPE html> <title>Pega test page</title> <head> <script src='https://xxxxxxxxxxxxxxx/prweb/app/default/?pyActivity=pzIncludeMashupScripts'></script> <script src="domWrapper.js"></script> <script src='PegaHelperExtension.js'></script> <script src='PegaHelper.js'></script> <link rel="stylesheet" type="text/css" href="PegaStyles.css?nocache=20200611T145831.601GMT"> <script> // this will not be called until the button is clicked function loadChat() { window.setContactId(12345) window.chat.init() window.chat.enable(true) } </script> <style> .content { font-family: Arial, Helvetica, sans-serif; max-width: 1024px; margin: 0 auto; } </style> </head> <body> <div class="content"> <h1>2) Load chat widget on demand - not working</h1> <p> This is a non-working version that attempts to load the chat widget on-demand, which is what the application will need to do after the user identifier is loaded asynchronously. </p> <p><strong>Click Load chat to load the chat widget:</strong><br /> <a href="#" onclick="loadChat()">Load chat</a></p> </div> </body> </html>
please suggest how can we do it.
When using the Customer Service Chatbot, the OOTB implementation passes the customer context data dynamically. That means that at the time the customer clicks on the "Need Help" button, the customer context is evaluated at that time and passed in. If by the time the customer clicks the button and the context is not set, it will be passed as empty.
Pega suggests against hiding the button until the context is set. This can lead to potential race conditions and cause the button to not appear when it should. Also, just because a customer is not identified, it should not prevent that customer from being able to take advantage of the chat feature.
Amit