在不使用 iframe 的情况下将 Chatbot 集成到网站中

Integrate Chatbot into a website without using iframes

我已经使用 Microsoft Bot Framework 创建了一个聊天机器人,现在我想在不使用 iframe 的情况下将它集成到我的网站中,但我不知道该怎么做。 你能帮我么? 请给我指明正确的方向。

他们构建了 React component 作为使用 iFrame 的替代方法。

import { Chat } from 'botframework-webchat';

...

const YourApp = () => {
    <div>
        <YourComponent />
        <Chat directLine={{ secret: direct_line_secret }} user={{ id: 'user_id', name: 'user_name' }}/>
        <YourOtherComponent />
    </div>
}

...

编辑:

首先你需要安装react chatbot组件。 运行 pm install botframework-webchat 在您的终端中。这将安装一个名为 botframework-webchat 的新包。然后在您的主要 <App /> 组件中,您需要像这样从包中导入组件:import { Chat } from 'botframework-webchat';.

现在您可以访问 <Chat /> 组件并可以像使用任何其他组件一样使用它。您需要为该组件提供两个道具:您的 direct_line_secretuser 信息。

就是这样!