1

I've been working on this problem for a week now and I've got no further and was hoping someone had encountered this before. The documentation around this is frustratingly sparse and glosses over the particular issues i'm having trouble with.

So I have a bot I wish to integrate into a teams application, but before that I wanted to test it in the emulator and ensure it works in Azures Test in Webchat feature. The Web App Bot is hosted on Azure, as is the App Bot Service, which is what I deploy to. When I test it in web chat, There is an error in my browsers console, and in the Channel there is a listed issue stating "There was an error sending this message to your bot: HTTP status code Unauthorized"

What I assume is happening is that my Web App Bot is sending a malformed request to my web app service. But I don't understand why.

enter image description here

So, looking around here and other places, it looks like the cookie cutter answers for this are a combination of check your AppId and AppPassword are correct, make sure your endpoint is correct, make sure the admin has consented, test it in the emulator, update your bot framework nugets, make sure you subscribed your bot correctly, delete and resubscribe your bot etc etc, naturally all of these I've done.

I'm sure the Id and Password, endpoint, and consent are all correct, as I can connect to the bot fine in the emulator.

enter image description here

What I'm not clear on is the consent process. I think I've consented to everything I need to, but it might be worth double checking.

I've also tried remote debugging to see if it hits my code, and it does, but the postAsync() controller just throws out the request

[HttpPost, HttpGet]
public async Task PostAsync()
{
        // Delegate the processing of the HTTP POST to the adapter.
        // The adapter will invoke the bot.
        await Adapter.ProcessAsync(Request, Response, Bot);
}

Is there anything I need to configure, or any thing I can look into here? Azure can be a confusing place so it would be nice to have some advice from someone more knowledgeable.

So that's my question. Why am I not authorised to test this in Test Web Chat on Azure? And why do I get the same errors when I include the bot ID in my teams manifest?

Robbo
  • 87
  • 9

2 Answers2

0

Make sure these things:

  1. When you connect your Bot just mention the URL of the Bot Channel.

  2. The UnAuthorized message comes when you have (unintentionally) mentioned MicrosoftAppId and MicrosoftAppPassword in your appSettings.json. Make sure you don't mentioned them. Pass empty string.

  3. If you have created your Bot in Azure Portal you will get the MicrosoftAppId (in Overview section) and MicrosoftAppPassword (in Keys or may be Security on left side of the Azure Portal Bot pane). Use these credentials when you Connect to a BOT and also in your appSettings.json

Note: Step-3 only applies if you have created a Web bot in Azure Portal. Ignore otherwise.

You can also visit this link: https://stackoverflow.com/a/49377915/6029001

Rohan Rao
  • 2,505
  • 3
  • 19
  • 39
  • For 1. Yep, I've done that. I know i'm connecting to the correct bot because I can remotely debug the code, and it's being called when I send a post. for 2. This is for locally testing, no? I'm not locally testing, at this point. for 3. Yes I've already done this. I'm using the microsoftappid in settings, and the secret in the manage section. Still getting unauthorised. – Robbo Jul 28 '20 at 17:27
  • @Robbo,Strange! It should work because I had same problem and it worked. No worries, please try these steps as well: https://stackoverflow.com/a/49377915/6029001 and let me know. – Rohan Rao Jul 29 '20 at 04:10
  • Nothing in that post helped. I've used every combination of appid and password I can find and nothing authorises. – Robbo Jul 30 '20 at 12:57
0

For those who stumble onto this thread, the answer was that I just had to delete my app service and deploy it again.

I originally created the service manually, and then used continuous deployment to deploy onto it, but I found that just deleting the app service, and having visual studio create the service for me, the bot suddenly began authorizing.

As far as I know, no configuration was different, so it must've been something to do with setup. Marking as solved.

Robbo
  • 87
  • 9