Reputation: 4292
I have created a Microsoft Teams bot that can create/update conversations and receives all kinds of events to an endpoint (channel created, channel renamed, ...).
I'm interested in channel names.
I can see the channel name in the channelCreated
and channelRenamed
event. But what about channels that are created before my bot joines the team? How can I get those channel names using the Bot Service/Framework API?
I understand that I could get the channel name from the Graph API. But to get access to the Graph API as a bot, I have to perform the admin consent dance which I would like to avoid.
Upvotes: 0
Views: 691
Reputation: 487
Use Microsoft.Bot.Builder.Teams.TeamsInfo:
var channels = await TeamsInfo.GetTeamChannelsAsync(turnContext).ConfigureAwait(false);
foreach (var channel in channels)
{
System.Console.WriteLine(channel.Name);
}
Upvotes: 3