我已经创建了一个聊天机器人使用微软机器人框架和机器人应用程序,在C#。我通过从机器人框架获得的iframe将网络聊天添加到我的html网站上。
现在,我想删除嵌入到网络聊天中的聊天标题。相反,我想添加我的聊天机器人的名字。那么我如何编辑我的html代码来删除聊天标题呢?
发布于 2018-03-16 13:05:46
如您所知,当您使用webchat时,会在您的网页中加载一个iframe来呈现您的机器人。所以你不能真的通过JavaScript改变iframe中的任何东西,除非它暴露出来。因此,你不能改变“聊天”的标题。
但是你能做的,就是使用How to add Web Chat to your website中提到的directline来渲染你自己的网络聊天。在这里,你可以完全控制渲染的内容和渲染的方式。
使用上面提到的链接设置聊天后,您可以在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更改它。示例代码片段:
document.getElementsByClassName("wc-header")[0].innerHTML = "<span>Chat bot's name</span>"

发布于 2018-09-08 01:52:03
通过将this更改为botconnector-webchat,您可以使用顶级botchat设置来启用/禁用/更改标题:
BotChat.App({
directLine: ...,
user: ...,
bot: ...,
resize: "detect",
speechOptions: ...,
chatTitle: false // use this
}, document.getElementById("bot"));https://stackoverflow.com/questions/49313064
复制相似问题