microsoft/BotFramework-DirectLineJS

WebSocket is not defined

patrickianco opened this issue · 1 comments

Hello, I'm following the basic usage for the sdk based on the documentation.

image

I get the error ReferenceError: WebSocket is not defined when starting the server.

Are there any examples of using the directlinejs package in the backend?

@patrickianco, for Direct Line to function in a Node environment, you need to install these two packages into your project and include them at the top of the file you are calling Direct Line in. If you do not, then you will get the error you are receiving. For reference, this requirement is listed in the docs under 'step 2', here.

global.XMLHttpRequest = require('xhr2');
global.WebSocket = require('ws');

As this should solve the issue, I am going to close this as resolved. If the issue persists, please feel free to reopen.