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.
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); }
If you inspect the text that comes back in the 1st message, it will be "deploy cosmosdb". In the 2nd message though, it will be "CS Bot deploy cosmosdb" which the QnAMaker is struggling to parse. What you want to do, before passing the query text to QnAMaker, is to remove the "@" mention entirely from the text.
This is a common issue, so the Bot Framework already has a method to deal with this. You haven't mentioned what platform you're developing on, but here is a link for dotnet to the RemoveRecipientMention method. I'm pretty sure there's an equivalent on Node, etc.
The final effect would be to convert your Activity's Text to be the same in both cases, which would result in the same response from QnAMaker.
That's exactly it. I just figured it out, too by debugging the bot locally. It's a shame this is happening because it's advertised as "no code". Only after downloading the bot's source and digging into the request, one would find out.
The problem I have now, is that I can't modify the incoming text before it gets passed on because the code is using
BotFrameworkHttpAdapter
I'm not sure how BotFrameworkHttpAdapter should be the issue - it looks like you might need to dig around more. The code you're looking for is probably inside a class with "Dialog" in the name
Oh my goodness! How could I miss this? If you download the source code (.net core) project of the bot, the README.MD even mentions this issue under "Microsoft Teams channel group chat fix"! I'll update my question with this finding.
lol. Glad you found it.