将Bot与Direct Line API集成

问题描述 投票:0回答:1

我有一个在SDK 4中开发并在IIS中部署的机器人。当我使用秘密与网络聊天集成时,它可以工作。

     window.WebChat.renderWebChat(
        {
            directLine: window.WebChat.createDirectLine({
                secret: 'SECRET CODE'
            }),
            // Passing 'styleOptions' when rendering Web Chat
            styleOptions
        },
        document.getElementById('webchat')
    );

但是在上述情况下,样式选择非常有限。我想使用需要令牌交换的REACT。我不确定如何使用?意味着在客户端需要什么更改,在Bot端需要什么?我找不到任何描述性文档。如果我们可以同时在客户端和Bot端采样以进行令牌交换,那就太好了。

botframework direct-line-botframework web-chat
1个回答
0
投票

可以使用REACT设置您的网络聊天样式。 botframework-webchat存储库here具有显示此内容的示例和示例。对于令牌交换,您将要使用以下内容:

import { DirectLine } from 'botframework-directlinejs';
import React from 'react';
import ReactWebChat from 'botframework-webchat';

export default class extends React.Component {
  constructor(props) {
    super(props);

    this.directLine = new DirectLine({ token: 'YOUR_DIRECT_LINE_TOKEN' });
  }

  render() {
    return (
      <ReactWebChat directLine={ this.directLine } userID='YOUR_USER_ID' />
      element
    );
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.