Skip to content Skip to sidebar Skip to footer

How Can I Use Offline-directline For Microsofts Botframework V4?

I need to run the microsoft botframework v4 on-premise since company internal restrictions forbid me to register the bot on Microsoft Azure or use the connector in the cloud. My id

Solution 1:

Please refer to the instructions in the BotFramework-WebChat repo to see how to host Web Chat v4 in a website. You'll find something that looks like this:

<!DOCTYPE html><html><body><divid="webchat"role="main"></div><scriptsrc="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script><script>window.WebChat.renderWebChat({
        directLine: window.WebChat.createDirectLine({ token: 'YOUR_DIRECT_LINE_TOKEN' }),
        userID: 'YOUR_USER_ID',
        username: 'Web Chat User',
        locale: 'en-US',
        botAvatarInitials: 'WC',
        userAvatarInitials: 'WW'
      }, document.getElementById('webchat'));
    </script></body></html>

Rather than passing the same kind of object to window.WebChat.renderWebChat's directLine parameter as you would to BotChat.App's directLine parameter, you need to pass the object to window.WebChat.createDirectLine. The object in question is a DirectLineOptions object.

    window.WebChat.renderWebChat({
        directLine: window.WebChat.createDirectLine({
            secret: params['s'],
            token: params['t'],
            domain: params['domain'],
            webSocket: false// defaults to true
        }),

If you don't want to have to pass in any parameters to your Web Chat client, you can include them inline:

secret:'',token:'',domain:'http://localhost:3000/directline',webSocket:false//defaultstotrue

And if you're not particular about running Web Chat in your own HTML page, I recommend foregoing offline-directline and just using the Bot Emulator, which is great for interacting with local bots.

Post a Comment for "How Can I Use Offline-directline For Microsofts Botframework V4?"