DirectLineJS客户端库

问题描述:

我想在我的Web应用程序(HTML5和Javascript)中使用DirectLineJS库。DirectLineJS客户端库

我遵循以下网站的指示。

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

难道这些指令应用于HTML/JavaScript的项目太多。或者,它们是与nodej相关的指令。

其实我在指令中使用了以下unpkg CDN文件。

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

任何人都可以共享任何提示或代码片段上如何利用上述库。

+0

您检查了这些样品:HTTP s://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-DirectLine –

但大部分代码都可以在HTML中使用的样本/站点说明使用TypeScript,(你只需要删除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 */, 
}); 
+0

@Ejadib我终于决定使用TypeScript和React。我能够引用botframework-directlinejs模块。但是,当我尝试编译我的打字稿文件时,最终出现以下错误 – rku0526

+0

您未包含错误 –

命名空间已经改变现在你可以使用DirectLine这样的:

var directLine = new DirectLine.DirectLine({ 
         secret: this.secret, 
         webSocket: false, 
         pollingInterval: 1000 
        });