【问题标题】:Microsoft BotFrameWork styleSet with hideUploadButton带有 hideUploadButton 的 Microsoft BotFrameWork styleSet
【发布时间】:2021-03-12 23:15:51
【问题描述】:

您好,我是 Microsoft Bot Framework 的新手,请原谅我的问题。

我正在尝试更改聊天机器人的样式,但遇到了无法通过 styleSet 禁用上传按钮的问题。

const styleOptions = {
        hideUploadButton: true,
        bubbleBackground: "red",
        bubbleBorderStyle: "solid",
        bubbleBorderRadius: "10px",
        bubbleFromUserBackground: "#5ce9ff",
        bubbleFromUserBorderRadius: "10px",
        groupTimeStamp: 3000,
        emojiSet: true,
        timestampFormat: 'relative',
        timestampColor: "red",  
      };

上面的代码工作正常,但是当我试图更改聊天机器人的背景图像时,我认为我需要通过 styleSet 传递 styleOptions,这就是其他一切正常工作的地方,而不是上传按钮,尽管我设置这是真的。

 const styleOptions = {
        hideUploadButton: true,
        bubbleBackground: "red",
        bubbleBorderStyle: "solid",
        bubbleBorderRadius: "10px",
        bubbleFromUserBackground: "#5ce9ff",
        bubbleFromUserBorderRadius: "10px",
        groupTimeStamp: 3000,
        emojiSet: true,
        timestampFormat: 'relative',
        timestampColor: "red",  
      };

      const styleSet = createStyleSet({
        ...styleOptions,
      });

      styleSet.activities = {
        ...styleSet.activities,
        backgroundImage:
          "url('https://i.pinimg.com/originals/79/5c/ab/795cabc4647f73b365e2e6eabd0f34dc.png')",
      };
      
      // render webchat
      function renderWebChat(token, userId, enableWSS) {
        console.log("starting webchat");
        window.WebChat.renderWebChat(
          {
            directLine: window.WebChat.createDirectLine({
              token: token,
              // domain: '//' + window.location.host,
              domain:
                "https://bot-web-connector-dot-anna-dev-bot-services.df.r.appspot.com",
              webSocket: !!enableWSS,
            }),
            styleSet,
            store: store,
            userID: userId,
            username: "You",
            locale: navigator.language || "en-SG",
          },
          document.getElementById("webchat")
        );
      }  

我不知道为什么当我以这种方式实现我的代码时它不会成​​功,谁能告诉我我的错误。

【问题讨论】:

  • 接受/赞成一个答案服务于更大的 Stack Overflow 社区和任何有类似问题的人。如果您觉得我的回答足够,请“接受”并点赞。如果没有,请告诉我我还能提供哪些帮助!

标签: javascript html botframework chatbot implementation


【解决方案1】:

目前styleOptions 似乎有一个小错误。同时,您可以通过以下方式实现隐藏上传按钮。

styleSet.uploadButton = {
  ...styleSet.uploadButton,
  display:
    "none",
};

希望有帮助!

【讨论】:

  • 感谢您的帮助,它对我很有效。实际上,我是通过另一种方法尝试在 styleSet 下面的 renderWebChat() 中传递整个 styleOptions 来完成的,它也有点工作。尽管如此,还是感谢您提供了这么多帮助!
  • 有一段时间这似乎是解决方法,但在某些时候上传按钮为我们返回。现在我正在寻找一种在使用 styleSet 时隐藏按钮的新方法
  • @Martijn,将此属性和值 hideUploadButton: true 直接传递到 styleOptions 似乎现在可以正常工作。我刚刚使用 v4.13.0 进行了测试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多