简体   繁体   English

如何在网络聊天中获取用户名

[英]How to get Username in Webchat

Im using the webchat control of the botframework. 我正在使用botframework的webchat控件。 I tried setting the username via the iframe using querystring. 我尝试通过使用查询字符串的iframe设置用户名。

https://webchat.botframework.com/embed/YOUR_BOT_ID?s=YOUR_BOT_SECRET&username=DESIRED_USERNAME&userid=DESIRED_USERID

unfortunately during the 不幸的是

(message.Type == ActivityTypes.ConversationUpdate)

 if (message.MembersAdded.Any(m => m.Id == message.Recipient.Id))
            {
                var connector = new ConnectorClient(new Uri(message.ServiceUrl));
                var response = message.CreateReply();
                string replyMessage = string.Empty;
                if (string.IsNullOrEmpty(message.From.Name))
                {
                    replyMessage += "Hello there!\n\n";
                }
                else
                {
                    replyMessage += "Hello "+ message.From.Name +"\n\n";
                }

My message.from.name is empty. 我的message.from.name为空。 Im confused, because when i send a message it appears that my username is already set. 我很困惑,因为当我发送消息时,似乎已经设置了我的用户名。 How come during the conversation update it is still blank? 在对话更新过程中它为何仍然空白?

在此处输入图片说明

This is not possible in the IFrame WebChat control. 在IFrame WebChat控件中这是不可能的。 Additionally, the user name you are setting is just for the display name as pictured in your screenshot. 此外,您所设置的用户名仅用于显示名称,如屏幕快照中所示。 This is not a feature and there are no plans to support it in the future. 这不是一项功能,将来也没有计划支持它。 This is probably not the answer you were looking for, but at least you can stop searching for the answer and troubleshooting. 这可能不是您要找的答案,但是至少您可以停止搜索答案和故障排除。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM