I configured a knowledge base at qnamaker.ai, published it, and created a bot using Azure Bot Service.
In Teams, I created a new bot app and associated it with the deployed bot. The bot is allowed for private chats, group chats, and teams.
- If I'm in a private chat and "ask" it "deploy cosmosdb", it comes back with the correct answer.
- If I'm using the bot in a team, by mentioning it "@CS Bot deploy cosmosdb", it doesn't know the anwer.
- If I mention the bot in the private chat, I see the same behaviour: no answer.
But to talk to the bot it MUST be mentioned, so where's the problem here?
UPDATE:
Thanks to Hilton's answer below, I noticed that when you download the bot source code (in my case, it's a dotnet core project), the README.MD file states this issue and how to fix it:
Microsoft Teams channel group chat fix
- Goto
Bot/QnABot.cs
- Add References
using Microsoft.Bot.Connector; using System.Text.RegularExpressions;
- Modify
OnTurnAsync
function as:public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default) { // Teams group chat if (turnContext.Activity.ChannelId.Equals(Channels.Msteams)) { turnContext.Activity.Text = turnContext.Activity.RemoveRecipientMention(); } await base.OnTurnAsync(turnContext, cancellationToken); // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); }