Find Username of skype from Microsoft Bot Framework Channel

 ̄綄美尐妖づ 提交于 2019-11-28 21:56:22

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

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