botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How to get user name at bot application

Open srinutamada opened this issue 9 years ago • 4 comments

I am using DirectLine api to connect my bot application. In my implementation, I have used below code block to send messages. My idea to use from property in the my bot application and for any kind of verification or communication. But in my bot application I am not able to get this property. So please help me with code snippet which can solve my problem.

Message message = new Message { FromProperty = User.Identity.Name, Text = paramMessage };

srinutamada avatar Jan 13 '17 23:01 srinutamada

Hi @srinutamada, it looks like you're using the Direct Line 1.1 API. This API does not support usernames. Direct Line 3.0 does -- you can find the Beta Nuget library here: https://www.nuget.org/packages/Microsoft.Bot.Connector.DirectLine/3.0.0-beta

You will have to enable "3.0 [PREVIEW]" on your bot's Direct Line configuration page. Otherwise the API is fairly similar.

dandriscoll avatar Jan 14 '17 03:01 dandriscoll

Thanks for your information.

Do you have any working code to send a message with user name to bot application. It seems most of the methods and implementation got change compare to 1.1 version.

srinutamada avatar Jan 17 '17 04:01 srinutamada

Hi @srinutamada, this sample helps show how to send messages with Direct Line 3.0: https://github.com/Microsoft/BotBuilder-Samples/blob/master/CSharp/core-DirectLine/DirectLineClient/Program.cs

You can find the user's ID and name in the Activity message sent to your bot, within the activity.From field.

dandriscoll avatar Jan 28 '17 11:01 dandriscoll

Closing as it looks like the question has been answered. Please open a new issue if you'd like to discuss further.

dandriscoll avatar Mar 06 '17 16:03 dandriscoll