Authentication with BOT
Hi, I have put my bot on webchat. no authentication as of. Now I want to add authentication. We have microsoftonline authentication for our website. I want to put bot on this website. so as soon as I say Hi to Bot, he will recognize my name and reply me with my name. Any suggestion how should I go ahead. I want to pass token from our website to bot.
Most of examples which I saw, are like give user a link to click, get authenticated and return to bot. But, what if Bot channel is website and user is already logged on to website, then bot asking user to sign in again doesnt sound good idea to me, so this question is here.
I know this is quite open ended question. please suggest.
Regards, Ashay
hi @ashay-88 Check out AuthBot it's a great way to integrate AAD or any other form of OAuth in to your bot!
Hi @brandonh-msft I checked this sample. This one asks users to go to particular page to sign in and then returns magic number and resumes. What if I have already signed on to my website, which has this bot. My bot has web as channel. this is kind of passing token from some sharepoint website or .net application to Bot.
Is this doable?
Any equivalent for this on Node.js? thanks
any information?
cc @matvelloso
The next version of the web chat control will allow that. But not this one. Today the only way you could achieve this experience is by custom building your web control over directLine channel, then injecting whatever parameters via javascript into the channelData
@slidenerd I'm working on a nodejs equivalent. Would love your feedback. https://github.com/mattdot/botauth/
@dandriscoll or @matvelloso can you comment or close as appropriate?
Hi @ashay-88, we've released a new OSS web chat control you can clone and host in your own webpage. You can pass in a user ID and other data, all of which is sent directly to your bot. More details at https://github.com/Microsoft/BotFramework-WebChat
Let me add a little more detail about this scenario. @dandriscoll is right that our new WebChat control opens the door to this functionality.
The situation as I understand it is that your web page has an embedded WebChat control which is communicating with your bot. The page already has an authentication token and you want to send it to the bot. This is a much-requested scenario, and we are working hard to provide first class support for it, but right now it is a very manual process.
At the moment you will not be able to do this using the WebChat channel, which embeds a WebChat control via IFRAME. You will instead need to embed the control inline using the OSS WebChat project Dan referenced. Here are some light instructions for React and non-React websites. In both cases you create a DirectLine object (let's call it dl) which is passed to the chat control. This object does the actual communication with your bot, and your page can use it to send messages to your bot via the following JavaScript:
dl.postActivity({type:"message", from: {id: /* user id you provide */}, text:"auth", channelData: {auth: /* auth token you provide */}});
Your bot will need to specifically look for a message with the text "auth" and then pull the auth token out of message.sourceEvent["auth"]. You can of course rename the message text and/or channelData field to anything you like.
I hope this helps.
Thanks @dandriscoll I am checking that control now. Thanks @billba for your brief details..,much useful, appreciated.
Closing due to age. Please feel free to at-mention or open a new issue if you'd like to discuss further.