Uncaught TypeError: Cannot read property 'renderWebChat' of undefined

Uncaught TypeError: Cannot read property 'renderWebChat' of undefined

我正在创建嵌入在 iframe 源中的网络聊天。我想要的是更改该 iframe 中每个聊天消息(称为聊天气泡)的背景颜色。

这是我的代码:

<div id="webchat" role="main">
        <iframe src='https://webchat.botframework.com/embed/...?s=SECRET_KEY_HERE'
        style='min-width: 400px; width: 100%; min-height: 500px;'></iframe>
</div>

<script type="text/javascript">

const styleOptions = {
    bubbleBackground: 'rgba(0, 0, 255, .1)',
    bubbleFromUserBackground: '#ddd'
};

window.WebChat.renderWebChat({
    directLine: window.WebChat.createDirectLine({ secret: 'MY_SECRET_KEY_HERE' }),
    // Passing "styleOptions" when rendering Web Chat
    styleOptions
}, document.getElementById('webchat'));
</script>

问题:

我可以看到 Iframe,还可以使用专用密钥聊天;但是,我无法看到应用于聊天气泡和页面加载的样式我收到此错误:

Uncaught TypeError: Cannot read property 'renderWebChat' of undefined

这是什么原因?

这行不通,您混合了两种嵌入网络聊天的方式。

  1. Embed via iFrame
  2. Integrate with JavaScript

如果您想为网络聊天设置样式,则需要使用 JavaScript 集成。 JavaScript 集成有广泛的文档,其中显示 how to start and how to modify the web chat