gpt4 book ai didi

css - 更改嵌入为网络聊天的 QnA Bot 的 Css

转载 作者:太空宇宙 更新时间:2023-11-04 01:14:26 24 4
gpt4 key购买 nike

您好,我已经使用网络聊天嵌入了 QnA Bot。我需要更改聊天窗口标题的 CSS。

我将机器人作为网络聊天嵌入到 ASP.net MVC 应用程序中。

我正在使用 iframe 方法将机器人嵌入到 webchhat 窗口中。使用 iframe 方法如何更改 css。

还有从“聊天”到“点击提问”的默认文本

我下载了 botchat.css 和 botchat.js。我在 _Layout.cshtml 中包含了 css 和 js 文件。我在 botchat.css 中将元素“.wc-header”的背景颜色更改为红色。但是仍然没有反射(reflect)出变化。

我想知道为什么 botchat.css 显示 botchat.css 是从 https://webchat.botframework.com/css/webchat-stable/botchat.css

有人可以帮助我如何使网络聊天窗口获取我已经修改并包含在 _Layout.cshtml 中的 botchat.css。

提前致谢

最佳答案

您好,这是我为更改 QnABot 的 Css 和聊天标题所做的。

首先我将 iframe 放在 _Layout.cshtml 文件中。 iframe 的 src 是一个名为 MyFAQChat.html 的 HTML 文件

要生成 MyFAQChat.html 的内容,您可以执行以下操作。

首先像这样在 _Layout.cshtml 中只放置 iframe

<div id='botDiv' style='height: 30px; position: fixed; bottom: 0;right: 0; z-index: 1000; background-color: #fff'><div id='botTitleBar' style='height: 30px; width: 300px; position:fixed; cursor: pointer;'></div><iframe width='300px' height='300px' src='https://webchat.botframework.com/embed/YOURBOTHANDLE?s= secretforWebchat'></iframe>

然后使用 F12 您可以看到 iframe 的内容。它看起来像这样

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>MyBot</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
<link href="../../Content/botchat.css" rel="stylesheet" />

<link href="/css/webchat-stable/botchat-fullwindow.css" rel="stylesheet" />
</head>
<body>
<div id="BotChatElement"></div>
<script src="Scripts/jquery-1.12.3.js"></script>
<script src="Scripts/Custom/botchat.js"></script>

<script>
var model = {

"userId": "someuserid",
"userName": "You",
"botId": "botIDhere",

"botName": "botNamehere",
"secret": "webchatsecretidhere",

"directLineUrl": "https://webchat.botframework.com/v3/directline",
"webSocketEnabled": "false"

};
</script>
<script>
BotChat.App({
directLine: {
secret: model.secret,
token: model.token,
domain: model.directLineUrl,
webSocket: false
},
user: { id: model.userId, name: model.userName },
bot: { id: model.botId, name: model.botName },
resize: 'window',
locale: 'en'
}, document.getElementById("BotChatElement"));


</script>
<script>
$(document).ready(function () {
var id = document.getElementsByClassName("wc-header");
id[0].innerHTML="Click for Help";
});
</script>
</body>
</html>

您可以复制 iframe 的内容并将其另存为 HTML 文件。然后在 _Layout.cshtml 中的 iframe 中引用此 html 文件。

html 文件包含更改聊天窗口标题的代码。我正在将其更改为单击以获取有关 document.ready 函数的帮助。

要更改机器人窗口的 CSS..我首先从 cdn 下载 botchat.css 和 botchat.js,然后更改 css 并将链接添加到 MyFAQChat.html 中的 css。

这是我在没有使用 webchat repo 的情况下使用的方法。

我在document.ready函数中的layout.cshtml中添加了iframe

$(document).ready(function () {
var div = document.createElement("div");
document.getElementsByTagName('body')[0].appendChild(div);
div.outerHTML = "<div id='botDiv' style='height: 38px; position: fixed; bottom: 0; z-index: 1000; background-color: #fff'><div id='botTitleBar' style='height: 38px; width: 400px; position:fixed; cursor: pointer;'></div><iframe width='400px' height='600px' src='https://webchat.botframework.com/embed/DSWebBotForFAQs?s=0SRsueCeamk.cwA.JIM.ShMx5BDubHOaIOY3fxrdB_do7iBd1os'></iframe></div>";

document.querySelector('body').addEventListener('click', function (e) {
e.target.matches = e.target.matches || e.target.msMatchesSelector;
if (e.target.matches('#botTitleBar')) {
var botDiv = document.querySelector('#botDiv');
botDiv.style.height = botDiv.style.height == '600px' ? '38px' : '600px';
};
});

});

关于css - 更改嵌入为网络聊天的 QnA Bot 的 Css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50510099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com