Reputation: 1931
I am trying to use my Bot in Microsoft Teams and I have an issue when obtaining the username of each specific user that is using the Bot. A static variable cannot be used since there is only one server and multiple users. I am using this as a reference. Is there any way that I can make use of so that I can get each user's Username?
Upvotes: 0
Views: 776
Reputation: 572
Please note that when a user interacts with your bot, you will receive the name in the From section of the payload. We will also be adding user name in the Roster retrieval functionality so you can retrieve all team member names along with their UIDs.
In general, if you want to store names for future messages (e.g. push messages vs response), you'd need to use something like Bot Framework's user data store or for more robust support, something like Azure's Table storage.
Upvotes: 1
Reputation: 1931
I just used the AuthResult
class to get the user details. The following is the code that I write whenever I want to display the Username.
AuthResult authResult; context.UserData.TryGetValue(ContextConstants.AuthResultKey, out authResult);
And obtain the Username using authResult
.
i.e. authResult.UserName
Upvotes: 0