Is it possible to get user email from MS Teams with a Bot using SDK4?

前端 未结 2 1757
孤街浪徒
孤街浪徒 2020-12-21 06:50

I\'m using C# and Bot Framework SDK4 and need to get the user email from a 1:1 chat with my bot. Is it possible? All I can seem to get is ID and full name.

I have tr

相关标签:
2条回答
  • 2020-12-21 07:05

    You can! Per the docs, you just do the same as if you were getting the team roster, but use the conversation id, instead. For example:

    var credentials = new MicrosoftAppCredentials("<yourAppId>", "<yourAppPassword>");
    var connector = new ConnectorClient(new Uri(turnContext.Activity.ServiceUrl), credentials);
    var conversationId = turnContext.Activity.Conversation.Id;
    var userInfo = await connector.Conversations.GetConversationMembersAsync(conversationId );
    

    Note: I tried using the Microsoft.Bot.Connector.Teams package to do this, but couldn't get it to work. Had to use the connector method above.

    0 讨论(0)
  • 2020-12-21 07:05
    Private async  Task GetUserProfile(TurnContext context,CancellationToken cancellationToken)
    {
        BotFrameworkAdapter botAdapter = (BotFrameworkAdapter)context.Adapter;           
        var conversation = await botAdapter.GetConversationMembersAsync(context, cancellationToken);
    }
    

    You can visit - How get user email from MS Teams with a Bot using SDK4?

    0 讨论(0)
提交回复
热议问题