microsoft / BotFramework-Hubot

Hubot adapter for botframework
MIT License
111 stars 40 forks source link

How to get sender email address in Teams #26

Open paulsancer opened 6 years ago

paulsancer commented 6 years ago

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

MatSFT commented 6 years ago

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 commented 6 years ago

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

paulsancer commented 6 years ago

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? 🤔

MatSFT commented 6 years ago

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

paulsancer commented 6 years ago

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

MatSFT commented 6 years ago

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

paulsancer commented 6 years ago

@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).

MatSFT commented 6 years ago

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

casieo commented 5 years ago

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.

vaibhavkapur22 commented 5 years ago

Did anyone resolve this issue?

MatSFT commented 5 years ago

@vkapur I do not believe so.

paulsancer commented 5 years ago

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.

flologicshilpa commented 5 years ago

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

MatSFT commented 5 years ago

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

basxib commented 5 years ago

@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.

MatSFT commented 5 years ago

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

basxib commented 5 years ago

@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."

MatSFT commented 5 years ago

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

MatSFT commented 5 years ago

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

basxib commented 5 years ago

Yes

AkshatTR commented 4 years ago

Is there any solution for using TeamsInfo with sideloading apps?

MuriloTSGit commented 4 years ago

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

tithu commented 4 years ago

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

AkshatTR commented 4 years ago

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?

tithu commented 4 years ago

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?