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
` tags or `
– spicy.dll Oct 23 '19 at 15:35` tags are not needed, as well as most entities (` ` or `<`). For more information, see [Formatting Help](https://stackoverflow.com/help/formatting).