Search code examples
c#asp.net-corebotframeworkchatbotmicrosoft-teams

how to find if the user interacting with bot is owner of the Team i.e. user's role is owner


I am working on creating bot for Microsoft teams in C#. User can interact with bot however there are some configurations that can be changed only by a Owner of the team i.e. user with role as Owner.

I wrote the below code and it gives me user details but the role is null and for the Type, it says type is user.

var teamMember = await TeamsInfo.GetMemberAsync(turnContext, turnContext.Activity.From.Id, cancellationToken);

Is there a way to get the details if the user is owner of the team?


Solution

  • I don't think you'll get what you need from GetMembersAsync, as you're finding out, but you can use MS Graph to get this info. Remember that a Teams team is also an MS 365 Group, so you can query the Group for Owners. See here.