BotFramework-Hubot icon indicating copy to clipboard operation
BotFramework-Hubot copied to clipboard

How to get sender email address in Teams

Open paulsancer opened this issue 7 years ago • 25 comments

Hello! Noob question: Is there a way to get the sender email address when using MS Teams channel?

paulsancer avatar Jul 03 '18 21:07 paulsancer

Yes, but I'm not sure that this adapter has the correct plumbing to do so. I think we made these changes before Teams provided the email address.

MatSFT avatar Jul 03 '18 21:07 MatSFT

Right here: https://github.com/Microsoft/BotFramework-Hubot/blob/8d0cf959ff651f49cb4454c26cae968bd092f3a0/src/msteams-middleware.coffee#L110

I believe one of the values that the user object has now is an email address, some name qualities, and the AAD object id

MatSFT avatar Jul 03 '18 21:07 MatSFT

Unfortunately, the email address is not one of the properties of the activity?.address?.user object. The object is:

{ id: 'xxxxxx',
  name: 'polkien',
  aadObjectId: 'xxxxxx' }

Any other idea? 🤔

paulsancer avatar Jul 03 '18 22:07 paulsancer

The only other option would be to call the roster api upon message receipt: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-context#fetching-the-team-roster

MatSFT avatar Jul 03 '18 22:07 MatSFT

Nice! I will take a look and update this thread with my progress.

paulsancer avatar Jul 03 '18 22:07 paulsancer

Hey @Polkien were you able to make progress using the team roster API?

MatSFT avatar Jul 11 '18 16:07 MatSFT

@MattSFT, Sorry but the documentation I found for roster api is for creating teams apps (not sure how to integrate with this Hubot adapter). I need time to study everything and find a way to integrate these two pieces. Unfortunately I don't have enough time to spend on this right now but anyone else who has an idea or a clue is welcome to help! (please jeje).

paulsancer avatar Jul 11 '18 17:07 paulsancer

@Polkien yes this would be teams specific since other channels might not have a notion of email for a user.

MatSFT avatar Jul 11 '18 18:07 MatSFT

Hi, just checking to see if there are any updates on this, or possibly an ETA? It'd be great to be able to grab email address of people using Teams to communicate with bots.

casieo avatar Sep 20 '18 20:09 casieo

Did anyone resolve this issue?

vaibhavkapur22 avatar May 23 '19 16:05 vaibhavkapur22

@vkapur I do not believe so.

MatSFT avatar May 23 '19 17:05 MatSFT

Hi guys, sorry I leaved this thread but I don't even have access to a Teams instance anymore. @vkapur please try to figure out and open a PR.

paulsancer avatar May 23 '19 17:05 paulsancer

Any updates in this topic? I need this feature as well.

flologicshilpa avatar Jul 05 '19 09:07 flologicshilpa

You will need to call the roster to get the email address. It isn't available at the time of receiving a message unfortunately

MatSFT avatar Jul 11 '19 00:07 MatSFT

@MattSFT Do you have a reference for how to call the roster for the V4 of the SDK? I could only find reference for V3 which is incompatible with V4.

basxib avatar Jul 31 '19 08:07 basxib

This is how the BotBuilder SDK does it: https://github.com/OfficeDev/BotBuilder-MicrosoftTeams-node/blob/922d14e660cf5c5b9e510617b4cd01084483593d/samples/teams-bot/src/bot.ts#L63

MatSFT avatar Aug 01 '19 18:08 MatSFT

@MattSFT I tried doing that but I'm getting an error when calling either getActivityMembers or getConversationMembers,, the exception is "The bot is not part of the conversation roster."

basxib avatar Aug 01 '19 20:08 basxib

That usually happens if you are asking in a conversation where the bot has not been installed.

MatSFT avatar Aug 01 '19 21:08 MatSFT

Are you testing using sideloading? https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/apps/apps-upload

MatSFT avatar Aug 01 '19 21:08 MatSFT

Yes

basxib avatar Aug 02 '19 00:08 basxib

Is there any solution for using TeamsInfo with sideloading apps?

AkshatTR avatar Nov 26 '19 18:11 AkshatTR

Hello folks,

I'm trying to get user infos (email, name), anyone knows how can i do this and can explain to me in noob mode ? Thank you

MuriloTSGit avatar Dec 17 '19 20:12 MuriloTSGit

Any update on this issue? How can I retrieve email id of logged in user in teams in v3?

tithu avatar May 25 '20 09:05 tithu

You can get email of the logged in user with TeamsInfo class but the catch is you need to create a bot even if you only want a messaging extension. Crazy right?

AkshatTR avatar May 25 '20 13:05 AkshatTR

I guess TeamsInfo class is supported only in v4 SDK. Currently I have configured my bot in MS teams for v3 SDK. I don't want only messaging extension. I want users email id(actually teams login id) and want to use that for other purpose. Is there any way I can get email id of current user in BOT V3 SDK?

tithu avatar May 25 '20 14:05 tithu