[Node] DirectLine + WebSockets sample#87
Conversation
dandriscoll
left a comment
There was a problem hiding this comment.
A few small changes, and one addition of a call to the Token API would be perfect. Thanks!
| // Config settings | ||
| var useW3CWebSocket = false; | ||
| var directLineSecret = 'DIRECTLINE_SECRET'; | ||
| var directLineClientName = 'DirectLineClient'; |
There was a problem hiding this comment.
directLineUserId may be better
There was a problem hiding this comment.
Can you add the following comment above this variable?
// directLineUserId is the field that identifies which user is sending activities to the Direct Line service.
// Because this value is created and sent within your Direct Line client, your bot should not
// trust the value for any security-sensitive operations. Instead, have the user log in and
// store any sign-in tokens against the Conversation or Private state fields. Those fields
// are secured by the conversation ID, which is protected with a signature.
| var directLineSpecUrl = 'https://docs.botframework.com/en-us/restapi/directline3/swagger.json'; | ||
|
|
||
| process.argv.forEach(function (val, index, array) { | ||
| if (val === 'w3c') { |
There was a problem hiding this comment.
Can we just call the option "websocket" ? I don't think we refer to Web Sockets as W3C Web Sockets anywhere else. They're just regular Web Sockets to us :)
There was a problem hiding this comment.
Actually, I noticed below that W3C is a specific kind of socket exposed by Node? If so, this is OK.
There was a problem hiding this comment.
It is the same library, but the API exposed by the two versions change. The NodeJS version uses EventEmitter to trigger events, while the 'w3cwebsocket' follows the W3C spec using event handlers set as props, which is what WebBrowsers do.
| usePromise: true | ||
| }); | ||
| }) | ||
| .then(function (client) { |
There was a problem hiding this comment.
Can you also illustrate using the Token API to exchange the client's secret for a token?
| console.log('WebSocket Client Disconnected'); | ||
| }); | ||
| connection.on('message', function(message) { | ||
| if (message.type === 'utf8' && message.utf8Data.length > 0) { |
There was a problem hiding this comment.
Comment similar to:
// Occasionally, the Direct Line service sends an empty message as a liveness ping. Ignore these messages.
| @@ -0,0 +1,181 @@ | |||
| # Direct Line Bot Sample (using client WebSockets) | |||
|
|
|||
| A sample bot and a custom client communicating to each other using the Direct Line API. | |||
There was a problem hiding this comment.
Somewhere near the top of the sample, we should note the following:
- For many developers, the DirectLineJs project is an easy way to connect to the Direct Line in Node.js
- If you're interested in writing your own client without using DirectLineJs, use this sample
|
@dandriscoll Hi Dan, the feedback for the Node's DirectLine with WebSockets has been applied. |
No description provided.