1

I downloaded sample code from Mention sample;

var mention = new Mention 
{ 
    Mentioned = turnContext.Activity.From, Text = $"<at>{turnContext.Activity.From.Name}</at>" 
};
var replyActivity = MessageFactory.Text($"Hello {mention.Text}.");
replyActivity.Entities = new List<Entity> { mention };
await turnContext.SendActivityAsync(replyActivity, cancellationToken);

I tested the code using bot framework emulator. The mention user function works fine, and I can see 'Hello <at>User</at>' is returned as bot reply in emulator

When testing the code using Microsoft Teams, the mention user function doesn't work. 'BadRequest' error is thrown in AdapterWithErrorHandler class.

From Azure portal, (Bot Service->Channels->Microsoft Teams->Warnings in Health column), the message shows: Mention entity does not match text

The expected result should be: the user who chat with bot will be mentioned in the bot reply message. does any one knows why it works in emulator but doesn't work in ms-teams? I tried with several different version of Microsoft.Bot.Builder packages(>=v4.3.3), all versions have the same issue.

Updated: I fixed this issue by myself and close it. my channel account name in teams contains special char '&' which always made the mention function failed. add some logic to handle special chars in channel account name fixed the error of Mention entity does not match text

Gan Jun
  • 11
  • 4
  • Welcome to Stack Overflow! When formatting your question, please avoid excessive use of HTML entities and tags. Stack Overflow supports markdown, so that `

    ` tags or `
    ` tags are not needed, as well as most entities (` ` or `<`). For more information, see [Formatting Help](https://stackoverflow.com/help/formatting).

    – spicy.dll Oct 23 '19 at 15:35
  • That is...not a sample. At all. That's the test series to make sure the bot framework connectors work with Teams channel. Try one of [these](https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/teams/csharp-dotnetcore) – JJ_Wailes Oct 23 '19 at 16:20
  • @JJ_Wailes I tried sample from the link that you provided. [Mention Sample](https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/teams/csharp-dotnetcore/Mentions). the code is same with the link that i used yesterday. only difference is one is using project reference of Microsoft.Bot.Builder, the other is using package reference. tested the sample that you provided, still experienced the same error. it works fine in bot framework emulator, but for ms-teams still shows 'Badrequest' in `AdapterWithErrorHandler` class and **Mention entity does not match text** in Bot Service – Gan Jun Oct 24 '19 at 02:57

0 Answers0