microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.47k stars 2.44k forks source link

403 User Blocked Bot Error Unexpected #6655

Open mcat97 opened 1 month ago

mcat97 commented 1 month ago

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

4.21.4

Describe the bug

  1. Our test user has mysteriously had the bot blocked, despite no one ever having blocked it before. We didn't know it was a thing. Other developers have nuked their local bot in order to get beyond this issue, but never understood how the user came to have the bot blocked.
  2. Since the above happened, we noticed upon sending an adaptive card, using the method Member_2.sendAdaptiveCard with no errorHandler passed in for onError, we get a 403 User blocked the conversation with the bot. Of course, this is expected as we now are purposely blocking the bot to test sending cards. However, what we do not understand is why when someone has the bot blocked, the 403 causes the bot to entirely crash and send the pre-fabbed User blocked the conversation with the bot messages to the channel the bot is in. We cannot find documentation to help us better understand how to elegantly handle this error.

To Reproduce

Steps to reproduce the behavior:

  1. Install the Microsoft Teams bot to a Channel -- i.e. "General".
  2. Have "User A" in this specific General Channel
  3. Have "User A" block the bot you installed in the General Channel (done via triple dot menu in the chat tab, after messaging the bot directly)
  4. Have your installed Microsoft Teams Bot send an adaptive card using the method member.sendAdaptiveCard (i.e. Member_2.sendAdpativeCard)

Expected behavior

Upon completing the reproduction steps, you should see your bot sends 2 messages to the "general channel" (a message of the error, and a message to fix the source code) and produces an "unhandled error" within your console.

What we expect to happen: Give a clear and concise description of what you expected to happen. We expect the message to not send, but we do not expect the bot to crash and be told the error is unhandled.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here. If someone could help us understand if there are any other ways a bot ends up blocked by a user without using the triple dot menu in the chat section, it would help us write documentation for our end users. Additionally, examples and documentation on how to better and more elegantly handle the 403 error would be extremely appreciated. Apologies in advance if this isn't there this isn't meant to go, but after a few conversations we feel the two scenarios scream more like a potential bug than a stack overflow issue.

Tracking Status

Dotnet SDK [TODO]()

Javascript SDK [TODO]()

Python SDK [TODO]()

Java SDK [TODO]()

Samples [TODO]()

Docs [TODO]()

Tools [TODO]()

dmvtech commented 1 month ago

I assume this is in Microsoft Teams? And that this issue is the same?

Can you please give more information about the repro steps? I assume when you say "to the channel the bot is in", you mean a Teams channel (not to be confused with a Bot channel such as Teams or Telegram).

mcat97 commented 1 month ago

I assume this is in Microsoft Teams? And that this issue is the same?

Can you please give more information about the repro steps? I assume when you say "to the channel the bot is in", you mean a Teams channel (not to be confused with a Bot channel such as Teams or Telegram).

Yes those issues are the same.

Regarding the reproduction steps, I will go in and add detail where I can (however there isn't much to it, so forgive me and let me know what you feel you are missing if there is anything). In reference to "to the channel the bot it in", correct, I mean the Microsoft Teams Channel the bot was installed in.

dmvtech commented 1 month ago
  1. Have "User A" in this specific General Channel
  2. Have "User A" block the bot you installed in the General Channel

I'm not able to accomplish this part (in my environment). I don't seem to have the option to block the bot in a channel. Would you happen to know if there are specific permissions needed to get that option?

Additionally; how are they blocking it? Are they doing that from the ellipsis when hovering over the bot in a channel? Please give more info on exact steps to block the bot.

I know that to block a bot in a 1:1 conversation, you can click on the bot and select Block bot converstation. Not sure how to from within a channel.

mcat97 commented 1 month ago

I'm not able to accomplish this part (in my environment). I don't seem to have the option to block the bot in a channel. Would you happen to know if there are specific permissions needed to get that option?

There should not be any permissions to need to block the bot. If the bot has posted in the channel (like a welcome message, as ours does), message the bot and then block it from the chat side menu SCR-20240723-kosf SCR-20240723-kpdn

Additionally; how are they blocking it? Are they doing that from the ellipsis when hovering over the bot in a channel? Please give more info on exact steps to block the bot.

Please see above

I know that to block a bot in a 1:1 conversation, you can click on the bot and select Block bot converstation. Not sure how to from within a channel.

You cannot block the bot from the channel, when I mention blocking the bot in the channel you installed, I was just providing extra detail to specify which bot to block, not to do the blocking within the channel. Apologies for any confusion.