1
votes

I am in the process of building a chat bot that will integrate with Teams or Slack. To get started I am using the echo bot template, but I am adding it to an exiting API that I have in my Service Fabric Cluster.

When running the application locally, I can connect to it fine from the Bot Emulator, but when I deploy it to my Azure channel registration, and test it in the web chat I get:

There was an error sending this message to your bot: HTTP status code Unauthorized.

I am setting the AppID and Password and they are saved and being retrieved from KeyVault, and I throw an exception at startup if either of the values are blank (which is not the case).

I set it as follow:

services.AddBot<EchoBot>(options =>
            {
                options.CredentialProvider = new SimpleCredentialProvider(Configuration["MicrosoftAppId"], Configuration["MicrosoftAppPassword"]);
                options.OnTurnError = async (context, exception) =>
                {
                    ServiceEventSource.Current.Message(exception.Message);
                    await context.SendActivityAsync("Sorry, it looks like something went wrong.");
                };
            });

I have added a teams channel, where the error does not occur, but the message never reaches the server.

The service is reachable and the controller allows unauthorized credentials while this is in testing.

1
Please check out this sample: github.com/microsoft/BotBuilder-Samples/blob/master/samples/… the services.AddBot in the code shared here is a different di configurationEric Dahlvang
I tried doing it this way first, and it didn't work.Steve

1 Answers

2
votes

Solved my own issue. It turns out that if you are using a self signed certificate, then this could occur, as per Microsofts documents found here -

If one or more error(s) are indicated in the chat window, click the error(s) for details. Common issues include:

  • The emulator settings specify an incorrect endpoint for the bot. Make sure you have included the proper port number in the URL and the proper path at the end of the URL (e.g., /api/messages).
  • The emulator settings specify a bot endpoint that begins with https. On localhost, the endpoint should begin with http.
  • In the emulator settings, the Microsoft App ID field and/or the Microsoft App Password do not contain valid values. Both fields should be populated and each field should contain the corresponding value that you verified in Step 2.
  • Security has not been enabled for the bot. Verify that the bot configuration settings specify values for both app ID and password.

Lessons Learnt

  • Read the doc's

  • When you get frustrated, calm down and read the doc's