ryanvolum / offline-directline

Unofficial package to emulate the bot framework connector locally.
https://www.npmjs.com/package/offline-directline
78 stars 44 forks source link

TypeError: Cannot read property 'subscribe' of undefined #48

Open simon-tannai opened 4 years ago

simon-tannai commented 4 years ago

Hello ! :)

I'm trying to use Offline Directline with Docker. My bot and the Offline Directline are running fine, but from the Webchat, I got this error: TypeError: Cannot read property 'subscribe' of undefined.

Here my simple HTML webchat's page:

<!DOCTYPE html>
<html>
   <body>
      <div id="webchat" role="main"></div>
      <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
      <script>
         (async () => {
            const userId = 'dl_123'
            const secret = 'MY_SECRET'

            const rawResponse = await fetch('https://directline.botframework.com/v3/directline/tokens/generate', {
               method: 'POST',
               headers: {
                  'Accept': 'application/json',
                  'Content-Type': 'application/json',
                  'Authorization': 'Bearer ' + secret
               },
               body: JSON.stringify({
                  User: { Id: userId }
               })
            });

            const content = await rawResponse.json();

            window.WebChat.renderWebChat(
               {
                  // directLine: window.WebChat.createDirectLine({
                  //    token: content.token
                  // }),
                  directLine: {
                     secret,
                     token: content.token,
                     domain: 'http://127.0.0.1:3000/directline',
                     webSocket: false,
                  },
                  userID: userId,
                  username: 'testuser',
                  locale: 'en-US',
                  botAvatarInitials: 'WC',
                  userAvatarInitials: 'WW'
               },
               document.getElementById('webchat')
            );

            console.info(`Webchat initialized with token ${content.token}`)
         })();
      </script>
   </body>
</html>

From Postman, an HTTP request OPTION 127.0.0.1:3000/directline returns a 200 status code.

Did I missed something on Webchat configuration ?