Get the user information from teams using Bot framework composer

1.1k views Asked by At

I had created a bot using bot framework composer and integrated it with MS Teams with help of the azure web app. Now I need to get the login user(MS Team) information i.e. the user who using the bot. I need to get the user information and log it in the azure application insights using Bot Framework Composer.

Can anyone help me with it?

2

There are 2 answers

0
Đèo Nguyễn Văn On
  1. Get UserID from ${turn.activity.aadObjectId}
  2. Get more user information by Microsoft Graph: https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http
0
Neil On

In MS Teams, with each new interaction with the bot, a "conversation Update activity" is first sent to the bot, this is what triggers the welcome greeting. You get back the following context in the returned JSON - in the Turn.Activity memory scope.

...snip... 

   "serviceUrl":"https://smba.trafficmanager.net/emea/",
   "channelId":"msteams",
   "from":{     
      "id":"<<Unique MS Teams Identifier for the end user>>",
      "name":"<<AAD firstname surname is returned here>>",
      "aadObjectId":"<<GUID is returned here>>",
      "role":"user"
   },

...snip... 

You can Use the aadObjectId to query the MS Graph using an HTTPRequest if you want to get further info. Or just use the persons "name" field (which is from AAD) if that is good enough.