如何使用 SDK4 通过 Bot 从 MS Teams 获取用户电子邮件?
How get user email from MS Teams with a Bot using SDK4?
我们在 MS-Teams 频道上部署了我们的 bot 应用程序,因此出于授权目的,我们需要 MSTeams 登录用户的电子邮件 ID,因此最初,我们面临从 Activity 对象获取 emailId 的问题。在做了一些分析之后,我们找到了一个解决方案,emailId 将使用 C#
从 ms-bot v4 中的 BotFrameworkAdapter class 获取
Private async Task GetUserProfile(TurnContext context,CancellationToken cancellationToken)
{
BotFrameworkAdapter botAdapter = (BotFrameworkAdapter)context.Adapter;
var conversation = await botAdapter.GetConversationMembersAsync(context, cancellationToken);
}
我们将从对话变量
中得到以下响应
{
"id": "UserConversationId",
"name": "Full Name of the user",
"aadObjectId":空,
"role":空,
"objectId": "Object Id",
"givenName": "FirstName",
"surname": "LastNamr",
"email": "OrganizationEmailId",
"userPrincipalName": "UserPrincipalName",
"tenantId": "TenantId",
"memberRole": "user"
}
我们在 MS-Teams 频道上部署了我们的 bot 应用程序,因此出于授权目的,我们需要 MSTeams 登录用户的电子邮件 ID,因此最初,我们面临从 Activity 对象获取 emailId 的问题。在做了一些分析之后,我们找到了一个解决方案,emailId 将使用 C#
从 ms-bot v4 中的 BotFrameworkAdapter class 获取Private async Task GetUserProfile(TurnContext context,CancellationToken cancellationToken)
{
BotFrameworkAdapter botAdapter = (BotFrameworkAdapter)context.Adapter;
var conversation = await botAdapter.GetConversationMembersAsync(context, cancellationToken);
}
我们将从对话变量
中得到以下响应{ "id": "UserConversationId", "name": "Full Name of the user", "aadObjectId":空, "role":空, "objectId": "Object Id", "givenName": "FirstName", "surname": "LastNamr", "email": "OrganizationEmailId", "userPrincipalName": "UserPrincipalName", "tenantId": "TenantId", "memberRole": "user" }