MS Team. Bot. TeamsInfo.GetMemberAsync returns 'Forbidden'

Occasional Contributor

Hi. 

Bot handles "Messaging Extension Query activity" (OnTeamsMessagingExtensionQueryAsync) request.

One by One chat (My User - User 1).

I need to know "My User" email address. I use 

await TeamsInfo.GetMemberAsync(turnContext, userId, cancellationToken);

Chat:

- "Bot - My User" works. 

- "My User - User 1" 'Forbidden' ("message\":\"The bot is not part of the conversation roster.\")

- "My User - User 2" works.

1) What's the reason? Are there any limitations? 

2) Maybe there is additional way to get "my" account (email address , domain name)?

3) Are there any ways to put into cache the current user (loged in Teams) email address?

I need to know the email address (user domain name) in each action (activity).

 

 

2 Replies

@Paul_By 

Could you please share sample details which you are referring.It helps us to repro the issue.

Workaround: I get 'TeamsChannelAccount' data (TeamsInfo.GetMemberAsync(...)) in "Bot-User" conversation (first step) and put it into 'UserState'. Then I can get and use it.
My Bot: "scopes": ["personal"]. Maybe this is the reason of the issue.