ryanvolum / backChannelBot

This is a basic bot that uses the DirectLine backchannel to send and receive event messages to an instance of WebChat
20 stars 8 forks source link

Bot framework code for backchannel bot #2

Closed trevjacobson closed 7 years ago

trevjacobson commented 7 years ago

Would you be able to post the bot source code that accompanies this front end project?

ryanvolum commented 7 years ago

As mentioned in the readme, the hosting code is part of the webchat samples: https://github.com/Microsoft/BotFramework-WebChat/tree/master/samples/backchannel

Apologies - I realize that having the two in different places is a bit confusing.

trevjacobson commented 7 years ago

Oh I understand now, I've made my bot in C#. How can I add my credentials to the backchannel/index.html to establish the connection. I'm trying to use my directline secret and my messaging endpoint. I believe this is the section for adding those credentials var user = { id: params['userid'] || 'userid', name: params["username"] || 'username' }; var bot = { id: params['botid'] || 'botid', name: params["botname"] || 'botname' }; window['botchatDebug'] = params['debug'] && params['debug'] === "true"; var botConnection = new BotChat.DirectLine({ secret: params['s'], token: params['t'], domain: params['domain'], webSocket: params['webSocket'] && params['webSocket'] === "true" // defaults to true });

I've tried to just hardcode relevant sections as:

id: "mybot" name: "tester"

and

secret: "mydirectlinesecret" domain: "http://myngroktunnel.com/api/messages"

but that doesn't seem to work. Also when I have the index.html running it has errors in the chrome dev tools uncaught ReferenceError: BotChat is not defined at index.html:96

I'm able to send/receive messages in the webchat but I'm not able to send/receive the events. How should I add my credentials to the index.html to connect properly to directline

ryanvolum commented 7 years ago

Ahh I see - you've got to create a bot at dev.botframework.com, deploy your bot code to it, subscribe to webchat, and grab your actual secret. Then you'll update your secret and domain in the code.

image