Search code examples
botframeworkmicrosoft-teams

How to get the information about all groupChats in which my bot is part of. MsBot framework for Teams (nodejs)


When someone add my bot to their groupchat I am receiving a ConversationUpdate event and I am storing it for future reference. But storing all conversationUpdate events(which I will get when someone add my bot to their chat) of all groupChats has become a problematic. Is their any function for getting the Information about all groupChats that my bot has added to. Like we have a function for listing all Teams channels ex:- TeamsInfo.getChannels(context)

I would be thankful for any help


Solution

  • I'm not aware of any way to do this - the best I could suggest is something like listing conversation members of existing chats, on the graph beta endpoint (https://learn.microsoft.com/en-us/graph/api/conversationmember-list?view=graph-rest-beta&tabs=http). However, that would mean (a) it needs to returns bots as members of the chat, which I'm not sure it does (b) you'd need to basically query EVERY possible group chat in the organisation and (c) you'd need access rights to do that (e.g. application access). So, it certainly sounds like just storing the conversation id upfront on your own would be a better bet.

    Recall that you can get the conversation id (if that's what you're looking for) from any event, not just conversationUpdate - even a regular message to your bot from a user in the chat will have the conversation id attached. Also, you've haven't stated what you need the conversation id for. Presumably it's for pro-active messaging, but in that case remember to store the service url as well.