【问题标题】:How to remove the chat caption from the webchat of chat bot如何从聊天机器人的网络聊天中删除聊天标题
【发布时间】:2018-09-08 01:52:02
【问题描述】:

我在 C# 中使用 MS Bot Framework 和机器人应用程序创建了一个聊天机器人。我通过从 bot 框架获得的 iframe 将网络聊天添加到我的 html 网站。

现在我想删除嵌入网络聊天的聊天标题。而不是我想添加我的聊天机器人的名字。那么如何编辑我的 html 代码以删除聊天标题..

【问题讨论】:

标签: c# html botframework


【解决方案1】:

如您所知,当您使用网络聊天时,会在您的网页中加载一个 iframe,该 iframe 会呈现您的机器人。因此,除非将其公开,否则您无法通过 JavaScript 真正更改 iframe 内部的任何内容。因此,您不能按原样更改“聊天”标题。

但是您可以做的是使用How to add Web Chat to your website 中提到的直线来呈现您自己的网络聊天。在这里,您可以完全控制渲染的内容及其渲染方式。

使用上述链接设置聊天后,您可以在 Chat.tsx 文件中找到并修改以下代码块。

<div className="wc-header">
    <span>{ typeof state.format.chatTitle === 'string' ? state.format.chatTitle : state.format.strings.title }</span>
</div>

修改为以下代码并编译:

<span>{ typeof state.format.chatTitle === 'string' ? "Chat bot's name" : "Chat bot's name" }</span>

或者另一种更简单的方法是引用 CDN 中的文件,然后使用 JavaScript 对其进行更改。示例代码 sn -p :

document.getElementsByClassName("wc-header")[0].innerHTML = "<span>Chat bot's name</span>"

【讨论】:

  • 虽然您的答案是正确的,但最好避免重复并将用户指向已回答的关于完全相同问题的问题:)
  • 你能把已经回答的问题的答案记下来吗? stackoverflow.com/questions/49292591/…
【解决方案2】:

this 更改为botconnector-webchat,您可以使用顶级botchat 设置来启用/禁用/更改标题:

BotChat.App({
  directLine: ...,
  user: ...,
  bot: ...,
  resize: "detect",
  speechOptions: ...,
  chatTitle: false // use this
}, document.getElementById("bot"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多