8

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?

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
maddy7781
  • 157
  • 1
  • 3
  • 8

2 Answers2

3

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

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
  • 1
    No sure what they were thinking, reason for my statement. If you were to map the display name to a db record, it would cause issues, since multiple users can have the sam name. How does one get around this? – Richard Bailey Apr 25 '17 at 20:47
0
//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;
}
Samadhan
  • 389
  • 1
  • 5
  • 18