How get user email from MS Teams with a Bot using SDK4?

本秂侑毒 提交于 2020-05-17 06:34:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!