[MS Teams] Bot doesn't work in a team
Bot Info
- Bot handle:
- App ID: ca5af081-f5c4-4b06-8ad7-a8f80e41024a
- SDK Platform: .NET
- SDK Version: QnAmaker
- Active Channels: Skype, MS Teams,
- Deployment Environment: Azure Bot Service,
Issue Description
Im having an issue with my bot, i created the bot with QnA maker. I can add the bot to my private chats in Teams and talk to the bot without any errors. When i add the bot to a team, it doesnt respond to my messages. The only message i get is: Sorry, there was a problem encountered with your request. My callback URL is: https://officebottesting.azurewebsites.net/api/messages
Code Example
I made the bot using QnAmaker.ai, i didnt code anything
Reproduction Steps
- Made the bot in QnAmaker.ai
- added the bot to the azure bot service
- added the bot into a team using the callback URL and said: "hoi"
Expected Behavior
the bot should react to my message
Actual Results
i get the error: Sorry, there was a problem encountered with your request
I am having the exact same problem (except, obviously, a different botname on the URL)
So this (https://msdn.microsoft.com/en-us/microsoft-teams/botsadd#adding-a-bot-for-11-chat-only) seems to indicate that by using the QnA -> Teams connector, it limits it to 1:1 chat only, and not a Teams Channel (there's a Note under #3). Not sure if I have a way of disconnecting and then re-connecting it correctly.
That’s strange, i don’t really know what the issue is. I hope this is fixable
@calarmstrong i tried your solution and it doesn't work. I created a new bot service in azure and tried connecting it to teams straight away. But i got the same error
How to load your bot into MS Teams
Quick MS Teams bot deployment checklist:
- Did your O365 tenant administrator enable sideloading of apps for your organization?
- Did you create an app package
- Did you sideload your bot app into the relevant team?
Recommended reading:
@nwhitmont my office 365 tenant allowed sideloading of apps. I use the option "create custom bot", is that the wrong one?
I will try to create an app package, i don't have a lot of programming experience.
i created the manifest.json file and succeeded in adding the bot into my team. But now the bot doesn't react to my questions. I keep on getting the message: "No match found", it seems like the bot can't access the knowledge base.
Can this be solved?
Hi iantje31,
No match found is what the bot says when QnA maker can't find a suitable pair that matches the user's question. Seems that the bot can communicate with the QnA service but it cannot understand the question. I suggest you to download your code and load it with Visual Studio, in order to be able to debug it:

You can modify the Post method in MessagesController.cs adding a new variable that reads the activity.Text:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.GetActivityType() == ActivityTypes.Message)
{
var message = activity.Text;
await Conversation.SendAsync(activity, () => new Dialogs.SimpleQnADialog());
}
Then you can set a breakpoint in that line, debug and see if the message the bot is sending to QnA is what you expect (it could be empty for some reason).
In addition to checking the question the user is sending to QnAMaker, you can monitor QnAMaker's answer by overriding the RespondFromQnAMakerResultAsync method like this:
protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
{
var answer = result.Answers.First().Answer;
Activity reply = ((Activity)context.Activity).CreateReply();
await context.PostAsync(reply);
}
https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator
@FranciscoPonceGomez thank you for your help! I will try to debug the bot tomorrow when i'm at work.
The bot does work when i run it in the bot emulator, does that mean that it should work in a team straight away or do you have to follow these steps in order to add it to a team?
I can't succeed in debugging the bot, whenever i press F5 to debug the code, i end on the following page:

the bot does work in the bot emulator, so i don't know what is causing the issue at the moment
This is the logging i get when i talk to the bot in the emulator:

You need to launch the service locally. In the solution explorer, right click -> properties. Make sure that you have selected the "Debug" option for the solution and the project Url is pointing to your localhost


In the web.config file you don't need to write your MAppID and password until you redeploy but you need to add again your knowledge base keys:
<appSettings>
<!-- update these with your Microsoft App Id and your Microsoft App Password-->
<add key="MicrosoftAppId" value="" />
<add key="MicrosoftAppPassword" value="" />
<add key="QnASubscriptionKey" value="YOUR SUBSCRIPTION KEY" />
<add key="QnAKbId" value="YOUR KBID" />
</appSettings>

Then, on the emulator, select your localhost + api/messages. Then you can add breakpoints in your code and you will be able to debug step by step on your machine.

If everything works well you might want to redeploy to azure. Everything points out to a problem with the channel not the bot but it is better if we make sure the bot is sending and receiving what we expect locally.
@FranciscoPonceGomez thank you for your information.

This is the output i get from the breakpoint. Is that the information you need?

This is the output when i talk to the bot on localhost. It seems to be performing normally, right?
I tried redeploying my bot to azure, unfortunately that didn't fix the issue
Looks like a problem with the channel configuration. So, if you ask the same question to the bot, on the emulator you get the right answer and on Skype and MS Teams you receive "Not match found!". Is that correct? I will try to reproduce the error.
@FranciscoPonceGomez When i ask the question to the bot on a private chat in teams, i get the right answer. Same for Skype and the emulator. When i ask the question in a channel on Teams i receive: No match found!
What is the full question stored in QnAmaker? What is the search text you are sending in both the chat scenarios?
@Wajeed-msft the full question im asking is: “hoi”, the answer im supposed to get is: “hallo, ik ben een office 365 bot”
@Wajeed-msft is asking the right question. What is the exact string that QnAmaker is trying to process? (Not what you see in the UI, in the debugger.)
I haven't verified this, but I'm pretty sure that the problem is that QnAmaker is not stripping the bot's name before trying to process the question, and it thinks the bot's name is part of the question. For example if your bot's name is Foo, when you type @Foo hoi what your bot sees is actually <at>Foo</at> hoi.
This is documented here and there is sample code for stripping the @mentions.
QnAmaker should be doing this for you automatically - if it did, it could say it supports Teams channels - but I'm guessing it doesn't. @FranciscoPonceGomez - if this is the issue, perhaps you can modify QnAmaker? It would be nice to support!
@billbliss that’s a really good question. I think i can’t look into the debugging data when im asking the question on microsoft teams. Is there a way to verify that this is the issue @FranciscoPonceGomez ?
@billbliss and @Wajeed-msft. Thanks for jumping in. I knew it was something related to the text sent to QnA but couldn't figure out why MS Teams was acting differently from another channels. I will talk to the QnA team and see what we can do.
@iantje31 I think @billbliss and @Wajeed-msft found the problem here. Please, follow the documented sample that they provided for stripping the mentions. You could also add a duplicated pair for the greeting using
Thank you very much @FranciscoPonceGomez @billbliss and @Wajeed-msft you have indeed found the problem!
I added "Officebottest1 Hoi" to my knowledge base and mentioned the bot again on Teams, and it worked!


I hope the QnA team can fix this issue, but i will try to use the workaround for now!