Reputation: 85
I am trying to use DirectLineJS library in my Web App (HTML5 and Javascript).
I followed the instruction from the following site.
https://github.com/Microsoft/BotFramework-DirectLineJS
Are these instruction applied to Html/Javascript project too. Or, they are the instruction related to nodejs.
Actually I used following unpkg CDN file as written in the instruction.
>> Use the unpkg CDN, e.g. <script src="http://unpkg.com/botframework-directlinejs/directLine.js"/>
But i stuck on how to proceed with this file creating object, starting conversation. I tried to look into the file content too. But looks pretty difficult to understand.
Can anybody share any hint or code snippet on how to utilize above library.
Upvotes: 2
Views: 1927
Reputation: 105
The namespace has changed. Now you can use DirectLine like this:
var directLine = new DirectLine.DirectLine({
secret: this.secret,
webSocket: false,
pollingInterval: 1000
});
Upvotes: 3
Reputation: 14787
The samples/instructions in the site are using TypeScript
, however most of the code can be used in HTML (you only need to remove the import { DirectLine } from 'botframework-directlinejs';
For example, you can use the following code to create the object:
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 */,
});
Upvotes: 0