问题
We have used C# and Bot Framework SDK4 for developing bot application and we have deployed the same on MS-Teams channel so for Authorization purposes, we required emailid of the MSTeams logged in user, so initially, we have faced some problems for getting emailid from the Activity object. but after doing some analysis we are getting email id from the BotFrameworkAdapter class in ms-bot v4 using C#
回答1:
Private async Task GetUserProfile(TurnContext context,CancellationToken cancellationToken)
{
BotFrameworkAdapter botAdapter = (BotFrameworkAdapter)context.Adapter;
var conversation = await botAdapter.GetConversationMembersAsync(context, cancellationToken);
}
We will get the following response from the conversation variable
{ "id": "UserConversationId", "name": "Full Name of the user", "aadObjectId": null, "role": null, "objectId": "Object Id", "givenName": "FirstName", "surname": "LastNamr", "email": "OrganizationEmailId", "userPrincipalName": "UserPrincipalName", "tenantId": "TenantId", "memberRole": "user" }
来源:https://stackoverflow.com/questions/61727804/how-get-user-email-from-ms-teams-with-a-bot-using-sdk4