question

preetibhati-2938 avatar image
0 Votes"
preetibhati-2938 asked GiftA-MSFT edited

Print custom username in Azure chatbot.

Hi Team ,
I am using the following code to print the custom username and ID.

ID is coming with the help of following code but name is not coming.

                 var ID = turnContext.Activity.From.Id;
                 var userName = turnContext.Activity.From.Name;
                 await turnContext.SendActivityAsync(MessageFactory.Text($"Hello and welcome- {userName}.{role}"), cancellationToken);
                 await turnContext.SendActivityAsync(MessageFactory.Text($"This Is your ID -{ID}"), cancellationToken);



can you please tel me is there any configuration for username in Azure portal side.

Thanks & Regards,
Preeti Bhati

azure-bot-service
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks reaching out.

Adding right service tag to get expertise from Azure bot service team.

0 Votes 0 ·

Thanks for your revert.

I am creating Azure chat bot using bot service. Can you please tell how can I delegate this query to
respective team using service tag?

0 Votes 0 ·

1 Answer

GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered GiftA-MSFT edited

Hi, thanks for reaching out. Here's an example of how to print username (BotBuilder Sample).

 // the channel should sends the user name in the 'From' object
 var userName = turnContext.Activity.From.Name;
 await turnContext.SendActivityAsync("You are seeing this message because this was your first message ever to this bot.", cancellationToken: cancellationToken);
 await turnContext.SendActivityAsync($"It is a good practice to welcome the user and provide personal greeting. For example, welcome {userName}.", cancellationToken: cancellationToken);







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.