首页 > 解决方案 > Watson Assistant Webchat 删除会话后聊天图标也消失了吗?

问题描述

javascript 新手我正在使用 Watson 助手网络聊天框架 ( https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-events#windowclose ) 进行网络集成。我可以更新 CSS 变量和其他配置,但是当我删除用户会话时,最小化聊天机器人图标也会消失。

     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);
      });

标签: javascriptdomibm-watsonwatson-assistant

解决方案


你想达到什么目的?

instance.destroy()将拆除整个网络聊天并删除启动器和与网络聊天相关的所有其他 UI 元素。这就是导致您所看到的内容的原因。(https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methods#destroy)。

instance.destroySession()将删除与网络聊天相关的所有浏览器存储,因此,例如,如果您想将用户从您的网站中注销,则不会留下任何识别数据。(https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methods#destroySession

当有人简单地关闭聊天时,我认为您不想调用这些方法中的任何一种,他们可能只是在看屏幕上的其他内容并想回到聊天中,但也许我错过了您的最终目标是什么这里。


推荐阅读