3

I am currently following Teams Conversation Bot sample. I have followed it to the letter as far as i can see.

What works.

When i talk to the bot though the web view

enter image description here

I can see it hitting the code on my localhost.

 protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            turnContext.Activity.RemoveRecipientMention();

            switch (turnContext.Activity.Text.Trim())
            {
                case "MentionMe":
                    await MentionActivityAsync(turnContext, cancellationToken);
                    break;

                case "UpdateCardAction":
                    await UpdateCardActivityAsync(turnContext, cancellationToken);
                    break;

                case "Delete":
                    await DeleteCardActivityAsync(turnContext, cancellationToken);
                    break;

                case "MessageAllMembers":
                    await MessageAllMembersAsync(turnContext, cancellationToken);
                    break;

                default:
                    var value = new JObject { { "count", 0 } };

                    var card = new HeroCard
                    {
                        Title = "Welcome Card",
                        Text = "Click the buttons below to update this card",
                        Buttons = new List<CardAction>
                        {
                            new CardAction
                            {
                                Type= ActionTypes.MessageBack,
                                Title = "Update Card",
                                Text = "UpdateCardAction",
                                Value = value
                            },
                            new CardAction
                            {
                                Type = ActionTypes.MessageBack,
                                Title = "Message all members",
                                Text = "MessageAllMembers"
                            }
                        }
                    };

                    await turnContext.SendActivityAsync(MessageFactory.Attachment(card.ToAttachment()));
                    break;
            }
        }

what doesn't work

It appears to send the response back but nothing appears in the response window. How do i test this if it doesn't show the response?

Ngrok error

After a bit more digging I can see that ngrok is getting an error back of sorts its a web page I managed to pick the following error out of it.

AggregateException: Failed to acquire token for client credentials. (AADSTS700016: Application with identifier '9e0d71-7665-4f24-8898-f82f9bebba56' was not found in the directory 'botframework.com'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.
Trace ID: 4bf53bae-84dc-4b16-98e8-e99b322dc200
Correlation ID: 3c249469-d177-49dd-989f-80044a3b9faa
Timestamp: 2019-11-12 08:41:56Z) (AADSTS700016: Application with identifier 'e0d71-7665-4f24-8898-f82f9bebba56' was not found in the directory 'botframework.com'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.

I have checked the settings on the bot and the application itself. They have the same secret and application client id.

enter image description here

botframework.com appears to contain a list of bots that were created on azure.

What i have tried.

  • Visual studio is running as administrator.
  • Chckedbotframework.com my bot is listed.

  • Users have the write to create apps in AD, I am currently the only user anyway.

enter image description here

  • dev tools logs shows its authenticating.
  • Edge and chrome

enter image description here

web chat errors

I can see in the bot that its logging errors with the web chat

enter image description here

The thing is the bot is responding.

Emulator

Running the emulator does work. The issue is when hosted.

cross posted

Issue #1974

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

1 Answers1

0

I realize this is an old thread but I just got hit by this today. After much pain, the fix in our situation was this:

  1. Go to Azure Portal > Azure Active Directory
  2. Click "App registrations"
  3. Find the registration for the bot app in question and click on it.
  4. Under Manage, choose Authentication.
  5. Change "Supported account types" to "Accounts in any organizational directory."

In retrospect: the AADSTS700016 error was thrown when trying to get the detailed info of the person the bot is chatting with via Microsoft.Bot.Builder.Teams.TeamsInfo.GetMemberAsync(). Since our "Supported account types" in the app registration was restricted, when the bot was running in a Teams Office365 Tenant that was different than our Azure AD Tenant, Azure AD was saying, "Nope." After flipping this, then GetMemberAsync() was able to authenticate aginst the Teams Office365 Tenant to obtain the requested user information. Yay!

pettys
  • 2,293
  • 26
  • 38