microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

[Skype for Business] Channel doesn't pass authentication credentials correctly #2808

Closed tomorgan closed 7 years ago

tomorgan commented 7 years ago

System Information (Required)

Issue Description

I have a .NET Bot Framework bot created using the template and tested on other channels and in the dashboard.

I've added the Skype for Business channel and performed the PowerShell cmdlets for my tenant. However, I constantly get the reply "Error happened in contacting target user".

I looked in the Bot Framework Dashboard for issues, and the problem is that the Bot Framework is getting back a 401 Unauthorized from my code. Remember that this works fine in other channels.

Suspecting a problem with how Skype for Business passes (or doesn't pass) the authentication tokens I commented out the BotAuthentication decorator. Suddenly everything works fine. So I think there's a problem with the Skype for Business channel and how it passes the authentication credentials, as this situation clearly isn't ideal.

Example Code

Suspect it will happen with any bot deployment.

Steps to Reproduce

  1. Create fully working bot test in other channels
  2. Add Skype for Business channel, configure PowerShell for O365 tenant
  3. Wait 24 hours, then attempt to IM Skype for Business contact

Expected Behaviour

I would expect Skype for Business to be able to pass the authentication credentials so that the bot code can continue to use the [BotAuthentication] decorator

Actual Results

Skype for Business endpoint only works correctly if [BotAuthentication] decorator is removed.

jsiegmund commented 7 years ago

+1 I'm seeing the exact same behavior, there's also a couple of SO posts of the same:

PrasenjitSaha commented 7 years ago

Hi, I am getting same error "Error happened in contacting target user" after adding Skype for Business Bot. I have tried omitting [BotAuthentication] but getting same error.

jsiegmund commented 7 years ago

Today I removed the endpoint for my bot and re-added it with a new sip (just to be sure) and sure enough: now it seems to work! There's still a few quirks (the conversation history seems to get lost) but the initial issue isn't there any more for me.

Mikhail2k15 commented 7 years ago

@jsiegmund Which Bot template did you user? I tried the same many times but I still have the "Error happened in contacting target user

jsiegmund commented 7 years ago

This was an existing bot based on the LUIS template.

tomorgan commented 7 years ago

Hi, Just to follow up on this and hopefully help out anyone seeing the same issue.

I spoke to someone of the SfB product team who was good enough to make contact and talk me through this. The reason I was seeing this problem was because I did not have the latest version of Microsoft.Bot.Builder. I needed to be running 3.5+ and I wasn't. I've written it up here (along with instructions for updating the NuGet package if you need that): https://blog.thoughtstuff.co.uk/2017/06/how-to-enable-your-bot-framework-bot-on-skype-for-business-part-2-or-how-i-followed-the-instructions-and-it-worked/

Hope this helps anyone else seeing the same issue.

Mods: as far as I'm concerned this is now a non-issue. There are maybe some useful takeaways to be had, like explaining why the update was needed, or preventing a user from adding the SfB channel unless they were on the latest code, but I'm nit picking here. Issue resolved from my side. 👍 :)

rohantare commented 7 years ago

@tomorgan , Thank you for detailed replies. I could get my bot up and running for SFB. However, I have some issues.

I am able to get replies from bot only if I login with another account in the same tenant. In order to test SFB channel,, i created test office365 tenant, which has 2 users. One is bot and one is another user. The bot answers well to the user in the same tenant. However, when user in different tenant tries to contact the bot, he gets error "Can't reach.."

Issue 1. Does your bot works cross domain?

Issue 2: I also noticed that bot can't display enums from form builder and adaptive cards, which works fine on Skype and webchat channel but not on SFB.

Any comments on above 2 issues?

rohantare commented 7 years ago

@tomorgan : Just had an update about the Issue2 that adaptive cards not supported on SFB. However, waiting for your comments on Issue1, about cross tenants.

Actually the normal user in newly created tenant is able to chat cross domain. Bot application is not.

Any help is appreciated at this point!

GauravDhavale commented 7 years ago

@tomorgan Landed on this page while searching for "How to get Authentication token of user communicating with Bot over Skype for Business channel"

I have created a Bot in Node JS using Microsft Bot Framework and is deployed on Skype for Business (SFB) channel.

Whenever a user interacts with Bot over SFB and asks to fetch some details, I want the Bot to get these details from my companies internal system using the user's authentication token which should have generated when user login to SFB.

So, is there any way to get user's token from SFB which the Bot can use to get the required information on user's behalf? My companies internal system, SFB uses the same Azure AD for user authentication. Any help is appreciated! Thanks

kisnam commented 6 years ago

@GauravDhavale were you able to solve the issue? I am aware that the post is almost an year old. But it is much appreciated to find what was the resolution.