简体   繁体   中英

Watson Assistant Webchat after deleting session the chat icon also disappears?

New to javascript I am using the Watson assistant webchat framework( https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-events#windowclose ) for web integration. I am able to update the CSS variables and other configurations but when I delete user sessions on minimizing the chatbot icon also disappears.

     window.watsonAssistantChatOptions = {   
          carbonTheme: 'g10',
          enableFocusTrap: true,
          onLoad: function(instance) {
          // Instance method to adjust specific CSS variables
          instance.updateCSSVariables({
            'BASE-font-family': '"Times New Roman", Times, serif',
            'BASE-width':'460px',
            'BASE-height':'500px',
            '$interactive-01': '#5dd7ec',
            '$interactive-03':'#002d9c',
            '$interactive-04':'#002d9c'
          });
      instance.openWindow();
      instance.writeableElements.headerBottomElement.innerHTML = ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Powered By <a href="https://teledental.com"><strong>TeleDental</strong></a>';
      instance.render();     
function handler(event)
 {
    instance.destroySession();
    instance.destroy();
    resolve();
  }
instance.on({ type: "window:close", handler: handler });  
    }
  };

            setTimeout(function(){
        const t=document.createElement('script');
        t.src="https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js";
        document.head.appendChild(t);
      });

What are you trying to accomplish?

instance.destroy() will tear down the entire web chat and delete the launcher and all other UI elements related to the web chat. This is what is causing what you are seeing. ( https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methods#destroy ).

instance.destroySession() will remove all browser storage related to the web chat so if you want to, for instance, log the user out of your website, there is no identifying data left behind. ( https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methods#destroySession )

I don't think you want to call either of these methods when someone simply closes the chat, they could just be looking at something else on the screen and want to come back to the chat, but perhaps I am missing what your end goal is here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM