我有开始对话的网络聊天代码。它在 Chrome 中运行良好,但在 IE 11 中不起作用。在机器人端,我想在 bot.on('conversationUpdate') 中从客户端读取一些初始数据。我应该在哪里以及如何将我的用户 ID 传递给机器人?
当前客户的代码:
<script>
window.fetch("https://xxxurladdress", { method: "POST" })
.then(function (res) { return res.json(); })
.then(function (json) {
const secret = json.secret;
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine(
{secret:secret }),
userID: "1588b0f6-50c3-416e-8970-1d86bad6c68b
}, document.getElementById("webchat"));
document.querySelector("#webchat > *").focus();
});
</script>
bot.on('conversationUpdate') 中的机器人代码:
bot.on('conversationUpdate', async function (message) {
if ((message.membersAdded && message.membersAdded.length > 0
&& message.address.user.role !== undefined)) {
let conversationId = message.address.conversation.id;
let userId = message.address.user.id;
在 IE 11 的情况下,bot 无法读取 user.id,而上述代码在 Chrome 中运行良好。