Hi @Vivek Nuna
From the information you provided, I understand that you have developed a Microsoft Teams app and are looking for a way to receive an event or message notification whenever a user blocks your app.
After researching this, it appears that, at this time, there is no specific event or notification in Microsoft Teams that alerts you when a user blocks your bot. According to official Microsoft documentation, the Bot Framework and Microsoft Graph only provide events such as conversationUpdate (for adding or removing members, installing, or uninstalling the app), as well as message and reaction events. There is no event triggered to indicate that a user has blocked or muted a bot.
However, as a workaround, you can still create a report to understand which users in your organization have blocked, muted, or uninstalled the bot. This information can be incredibly helpful for your organization's admins when broadcasting org-wide messages or driving app usage.
When you attempt to send a proactive message to the bot, if the user has blocked or uninstalled it, Teams will return an HTTP 403 Forbidden response code with the subCode MessageWritesBlocked. This response effectively indicates that the message sent by the bot was not delivered to the user.
Here is an example of what that 403 response code looks like:
HTTP/1.1 403 Forbidden
Cache-Control: no-store, must-revalidate, no-cache
Pragma: no-cache
Content-Length: 196
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
MS-CV: NXZpLk030UGsuHjPdwyhLw.5.0
ContextId: tcid=0,server=msgapi-canary-eus2-0,cv=NXZpLk030UGsuHjPdwyhLw.5.0
Date: Tue, 29 Mar 2022 17:34:33 GMT
{"errorCode":209,"message":"{\r\n \"subCode\": \"MessageWritesBlocked\",\r\n \"details\": \"Thread is blocked from message writes.\",\r\n \"errorCode\": null,\r\n \"errorSubCode\": null\r\n}"}
What the official documentation recommends you do when you receive this error:
- Delete the conversation reference from your cache/database for that user.
- Stop attempting to send messages to that conversation.
- Resume only when the user explicitly initiates interaction again (e.g., they send a message to the bot or re-open the chat). This action automatically unblocks it from the bot's perspective.
You can (and should) log this error in your bot's message-sending logic so you can track which users have blocked the app.
Reference: https://github.com/MicrosoftDocs/msteams-docs/blob/main/msteams-platform/bots/how-to/conversations/send-proactive-messages.md
I hope this information helps clarify the situation
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.