如何使用SDK4从带有Bot的MS Teams获得用户电子邮件? [英] How get user email from MS Teams with a Bot using SDK4?

查看:110
本文介绍了如何使用SDK4从带有Bot的MS Teams获得用户电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经使用C#和Bot Framework SDK4来开发机器人应用程序,并且已经将其部署在MS-Teams频道上,因此出于授权目的,我们需要登录用户 MSTeams 的emailid,因此最初,我们在从Activity对象获取emailid时遇到了一些问题.但是经过一些分析之后,我们使用C#

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#

推荐答案

Private async  Task GetUserProfile(TurnContext context,CancellationToken cancellationToken)
{
    BotFrameworkAdapter botAdapter = (BotFrameworkAdapter)context.Adapter;           
    var conversation = await botAdapter.GetConversationMembersAsync(context, cancellationToken);
}

我们将从对话变量

{ "id":"UserConversationId", "name":用户的全名", "aadObjectId":null, 角色":null, "objectId":对象ID", "givenName":名字", 姓":"LastNamr", "电子邮件":" OrganizationEmailId ", "userPrincipalName":"UserPrincipalName", "tenantId":"TenantId", "memberRole":用户" }

{ "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" }

这篇关于如何使用SDK4从带有Bot的MS Teams获得用户电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆