I have a bot application which I installed in my team, using team scope. Now when this application is uninstalled from team is there any event I can get/monitor?
I was going over the Microsoft documentation and tried following piece of code. According to this onTeamsMembersRemovedEvent
is called when bot or a member is removed.
export class MyBot extends TeamsActivityHandler {
constructor() {
super();
this.onTeamsMembersRemovedEvent(async (membersRemoved: ChannelAccount[], teamInfo: TeamInfo, turnContext: TurnContext, next: () => Promise<void>): Promise<void> => {
let removedMembers: string = '';
console.log(JSON.stringify(membersRemoved));
membersRemoved.forEach((account) => {
removedMembers += account.id + ' ';
});
const name = !teamInfo ? 'not in team' : teamInfo.name;
const card = CardFactory.heroCard('Account Removed', `${removedMembers} removed from ${teamInfo.name}.`);
const message = MessageFactory.attachment(card);
await turnContext.sendActivity(message);
await next();
});
}
}
But for me I do not receive this event when I remove the bot application. I remove the bot application manually from inside the apps by choosing uninstall.
When uninstalled the app by navigating to More options > Manage teams > Apps > Uninstall , teamMemberRemoved event got fired and got correct response.
{
"membersRemoved": [
{
"id": "28:aXXXXX04-e293-447c-951f-6a6971b3b66b"
}
],
"type": "conversationUpdate",
"timestamp": "2021-10-19T15:24:45.9499395Z",
"id": "f:e0d2c276-XXXXX-5d74-73ad-3c67b9b0ae4f",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "29:1qanOqiaR5gWE-aWoYPdYjB--mUmmVQFGddHxyb37WXc4FI-eD62pSxBJYoXXXXXeGyFlpiTzRd-fTCiBmNbeuQg",
"aadObjectId": "XXXXXc4d0-XXXXX-4154-a85f-a89cd77aefa8"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"tenantId": "3XXXXXef-XXXXX-4d60-XXXXX-0aXXXXX693df",
"id": "19:XXXXX53a099498f9e08679e58f1f7fc@thread.tacv2"
},
"recipient": {
"id": "28:aXXXXX-e293-XXXXX-951f-6a6971b3b66b",
"name": "XXXXX"
},
"channelData": {
"team": {
"aadGroupId": "XXXXXf3-fa01-XXXXX-bb62-201225dce9e4",
"name": "XXXXX",
"id": "19:XXXXX099498f9e08679eXXXXXf7fc@thread.tacv2"
},
"eventType": "teamMemberRemoved",
"tenant": {
"id": "36a708ef-XXXX-4d60-9de0-XXXXXXdf"
}
}}