Find Username of skype from Microsoft Bot Framework Channel

血红的双手。 提交于 2019-12-18 01:05:19

问题


I have implemented bot application for Skype using Microsoft Bot Framework (version 3.0.0.59).

I implemented how to retrieve the Skype Name & Id but I'm not being able to retrieve the username of the Skype account. How can I get username of my Skype account?


回答1:


It's not possible. Since the v3 version of the API the user is now represented by a unique user ID per bot. This is to provide an extra layer of privacy to the users (pretty much like Facebook).

In the From property of the MessageActivity you will only find the Id and the Name but not the username




回答2:


//Answer
if(activity.From.Name != null)
string userName= activity.From.Name;

//Example

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    if (activity.Type == ActivityTypes.Message)
    {
    string userName= "";
    if(activity.From.Name != null)
    userName= activity.From.Name;//Here we are getting user name
    ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
    Activity reply = activity.CreateReply(userName);
    activity.TextFormat = "markdown";
    await connector.Conversations.ReplyToActivityAsync(reply);

    }
    else
    {
    HandleSystemMessage(activity);
    }
    var response = Request.CreateResponse(HttpStatusCode.OK);
    return response;
}


来源:https://stackoverflow.com/questions/40503468/find-username-of-skype-from-microsoft-bot-framework-channel

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