2

我正在尝试在我的 Web 应用程序(HTML5 和 Javascript)中使用 DirectLineJS 库。

我按照以下站点的说明进行操作。

https://github.com/Microsoft/BotFramework-DirectLineJS

这些指令是否也适用于 Html/Javascript 项目。或者,它们是与 nodejs 相关的指令。

实际上,我按照说明中的说明使用了以下 unpkg CDN 文件。

>> 使用 unpkg CDN,例如<script src="http://unpkg.com/botframework-directlinejs/directLine.js"/> 但我坚持如何继续创建对象,开始对话。我也尝试查看文件内容。但看起来很难理解。

任何人都可以分享有关如何使用上述库的任何提示或代码片段。

4

2 回答 2

3

命名空间已更改。现在您可以像这样使用 DirectLine:

var directLine = new DirectLine.DirectLine({
                        secret: this.secret,
                        webSocket: false,
                        pollingInterval: 1000
                    });
于 2017-07-07T19:26:08.093 回答
0

站点中的示例/说明正在使用TypeScript,但是大多数代码都可以在 HTML 中使用(您只需删除import { DirectLine } from 'botframework-directlinejs';

例如,您可以使用以下代码创建对象:

var directLine = new DirectLine({
    secret: /* put your Direct Line secret here */,
    token: /* or put your Direct Line token here (supply secret OR token, not both) */,
    domain: /* optional: if you are not using the default Direct Line endpoint, e.g. if you are using a region-specific endpoint, put its full URL here */
    webSocket: /* optional: false if you want to use polling GET to receive messages. Defaults to true (use WebSocket). */,
    pollingInterval: /* optional: set polling interval in milliseconds. Default to 1000 */,
});
于 2017-04-04T13:18:13.283 回答