How to get username from skype or chatbot (any channel) in bot framework?
Getting user name from skype in botframework
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Samadhan Salgar188 pointsPosted May 23, 2017, 11:26 PM EDT
//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; }