Forum Discussion
How to get list of channels and members in teams bot
Hi,
I’m working on building a Microsoft Teams bot and came across the TeamsInfo.getTeamChannels(turnContext, teamId) method in the BotBuilder SDK. Could you help clarify how it works? Specifically, how does turnContext return data for a team? I’ve already assigned all the necessary scopes through the Teams Developer Portal. Do I still need to use Microsoft Graph APIs, or will this method handle everything?
Also, when calling this method, I noticed that one channel (the "General" channel) is missing from the response. What’s the best way to fetch a complete list of members and channels in a team where my bot is installed, especially since users are interacting with it in personal DMs?
[ { "name": undefined, "id": "19:nGtWIyKBcs0m93LgdScfymNX4_YhoaEj0Zo1@thread.tacv2" }, { "name": "newchannel", "id": "19:42baf94a1a3e86cb0@thread.tacv2" }, { "name": "testchannel", "id": "19:54b4ac2af6228c4573fff12@thread.tacv2" } ]
- The TeamsInfo.GetPagedMembersAsync(turnContext) method can be used in various activities, not just in onConversationUpdate. This method is designed to fetch a paginated list of members from a one-on-one, group, or team conversation. It is not limited to being set up in onConversationUpdate.
You can indeed utilize it in the onMessage handler or any other activity handler. When you pass the context received to GetPagedMembersAsync, it will provide the full list of members that are part of the team, not just the members involved in the specific conversation. This method is particularly useful for handling large teams, as it supports pagination to manage the retrieval of members efficiently.
- Meghana-MSFTMicrosoftThank you for reporting this, we will check this and get back to you.
- Meghana-MSFTMicrosoft
yashgandhi - Could you please refer the below doc and sample.
- yashgandhiCopper ContributorSorry it's not helpful ... everywhere docs are linked mostly incomplete and has no relevant info
I already mentioned i used that `turncontext` and u can see i received a response too but its has undefined as value also how to generate context token for teams rsc permissions .If you can provide me specific code or some snippet which i can follow else i am already fed up with Microsoft clueless support