问题
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