1

I have set up a bot registration channel that connects to my bot's endpoint. It works perfectly fine in Bot Framework Emulator.

I am having problems connecting to my bot through the "Test in Web Chat" page on the Azure Portal. I try to send a message, but nothing happens and all I see under the message is "Sending".

I will then go to the "channels" tab in the blade and see an error for web-chat: There was an error sending this message to your bot: HTTP status code Unauthorized.

When I try sending a message to the bot in Microsoft Teams, absolutely nothing happens. I do not even get an error. Under health on the Azure Portal it just says "Running".

Getting my bot to work in the web chat is not top priority though. I really want it to work in teams in the end.

a135
  • 119
  • 1
  • 6
  • 1
    Have you added the Microsoft App Id and Microsoft App Password? – Marc Asmar Dec 06 '19 at 15:10
  • Is that something I do with my manifest? – a135 Dec 06 '19 at 17:41
  • Have you added your Microsoft App ID and password to your bot code(appsettings.json in C# / .env in JS)? When you create a BCR, it generates an AppId for you but you need to generate a new [password](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-3.0#get-registration-password) which you need to add to your bot code in order to test on other [channels](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-3.0#update-the-bot). – ranusharao Dec 06 '19 at 18:24
  • @ranusharao Okay so in my '.env' file, I did the following: For "MicrosoftAppId", I put the Microsoft App ID. For "MicrosoftAppPassword", I put the secret key that I created (it will last a year). Am I doing this correctly? I restarted my bot but it still doesn't work in Teams... – a135 Dec 08 '19 at 03:15
  • Could you please share you app manifest so we can check he issue? – Trinetra-MSFT Dec 09 '19 at 07:52
  • This is my manifest: https://pastebin.com/mUA1d1Lr – a135 Dec 09 '19 at 19:53
  • Did you set the messaging endpoint for your bot to "yourNgrokUrl.io/api/messages"? – Trinetra-MSFT Dec 10 '19 at 08:13
  • Yes, but I did that in my bot channels registration, not in the bot's config. – a135 Dec 12 '19 at 00:11
  • @Trinetra-MSFT When I try and talk to the bot in Teams the log stream prints `BotFrameworkAdapter.processActivity(): 500 ERROR - Error: Bad Request` – a135 Dec 12 '19 at 21:16
  • I found this on StackOverflow and I think it might solve my problem but I am not sure what the BotID is... Is it the same as MicrosoftAppID? I am going to try to find out if it works: https://stackoverflow.com/questions/47046470/botframework-the-bots-msa-appid-or-password-is-incorrect my web.config is in /site/repository/.git/ – a135 Dec 12 '19 at 21:26
  • it doesnt seem to work – a135 Dec 12 '19 at 21:41
  • Yes, You replace Microsoft App ID to Bot ID, I will suggest you to use Bot ID in your manifest and web.config file. – Trinetra-MSFT Dec 13 '19 at 05:05
  • Well for where everything and anything that asks for a Bot ID I have put in my Microsoft App ID. I then restarted my bot and the same things are happening. I don't get why Microsoft makes this so complicated. The log stream is spitting this out whenever I message my bot in Teams: `BotFrameworkAdapter.processActivity(): 500 ERROR - Error: Bad Request` – a135 Dec 13 '19 at 18:02

2 Answers2

1

Wanted to comment but don't have enough points. There's a few different reasons for authorization. When creating the bot registration there's an option to 'only allow accounts from this organization', this needs extra configuration so if you picked this then change it to any account.

Also, you can often get more detailed error messages from the server's side (which aren't revealed to the user who gets hit with 403). Go to the bot's App service in Azure portal and go to "App Service Logs" near the bottom of the left menu. Enable "Application Logging (Filesystem)" (I also like to Level to Verbose and enable "Detailed Error messages" as well). Now go to "Log stream" in the left menu. It should now be connected. Try to access bot again and see what messages come in the log stream.

If you enable Application Insights that can also help

waleed
  • 451
  • 3
  • 11
  • Thank you for sharing this. I found some error stacks popping up after I sent a message to my bot. I am going to see if it is a result of any of my code. It is strange because none of these errors would happen when I message my bot from the Bot Framework Emulator... – a135 Dec 09 '19 at 19:59
  • Alright, so I saw some interesting differences in the logs when I use Teams and the Bot Framework Emulator. When I try messaging my bot in the Bot Framework Emulator, the emulator says "The bot's Microsoft App ID or Microsoft App Password is incorrect." and the log stream say `Unauthorized Access. Request is not authorized`. When I try with Teams, it will just say in the log stream `BotFrameworkAdapter.processActivity(): 500 ERROR - Error: Bad Request` – a135 Dec 12 '19 at 21:12
  • You need make sure your MicrosoftAppId and MicrosoftAppPassword are correct, it's usually in appsettings.json (or for older bots .bot file). Setting up the Bot registration can be tricky, I gave up trying to do it manually and just followed the instructions for using the arm deployment template provided – waleed Dec 15 '19 at 09:57
  • I have searched far and wide for both of these files on the entire server and cannot find them. Are you talking about the `.env` file? If so, I have the MicrosoftAppId and MicrosoftAppPassword exact. Something I have yet to try however is see if I have those variable names correct (ie. spelling and capitalization). They currently are `MicrosoftAppId` and `MicrosoftAppPassword`. I'm pretty sure that the last `d` in the first variable name is supposed to be lower-case. Regardless, I think I'm at the point where I need to reach out to Microsoft and get support directly. – a135 Dec 17 '19 at 15:07
0

The main reasons for bots not getting called are either the address is incorrect (either the root location of some part of the address, depending on how you're hosting it. As an example, an Azure Function will automatically add an extra "/api" early in the path) or, as you're finding, something to with the AppId and AppPassword not getting picked up correctly.

If it's the latter, which is what it sounds like here, then in principle it's a simple fix - you just need to make sure your AppId and AppPassword are (a) correct from the portal and (b) getting used correctly in your bot configuration.

The problem comes in with (b) above - there are a whole bunch of different samples on the internet, from Microsoft and others, both for C# and Node, and they use a ton of different ways to instantiate the bot and set it's AppId and AppPassword. Some of the examples, for instance, use an implementation of an "ConfigurationCredentialProvider" internally, which will try pull the appid/apppassword from your configuration file, but of course expect them to be in a specifically-named set of values (see here for more).

So, can you check in however you've implemented your bot, to see where/how the credentials are getting set exactly?

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24