SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-2938348%22%20slang%3D%22en-US%22%3EMS%20Team.%20Bot.%20TeamsInfo.GetMemberAsync%20returns%20'Forbidden'%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2938348%22%20slang%3D%22en-US%22%3E%3CP%3EHi.%26nbsp%3B%3C%2FP%3E%3CP%3EBot%20handles%20%22Messaging%20Extension%20Query%20activity%22%20(OnTeamsMessagingExtensionQueryAsync)%20request.%3C%2FP%3E%3CP%3EOne%20by%20One%20chat%20(My%20User%20-%20User%201).%3C%2FP%3E%3CP%3EI%20need%20to%20know%20%22My%20User%22%20email%20address.%20I%20use%26nbsp%3B%3C%2FP%3E%3CP%3Eawait%20TeamsInfo.GetMemberAsync(turnContext%2C%20userId%2C%20cancellationToken)%3B%3C%2FP%3E%3CP%3EChat%3A%3C%2FP%3E%3CP%3E-%20%22Bot%20-%20My%20User%22%20%3CSTRONG%3Eworks.%3C%2FSTRONG%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-%20%22%3CSTRONG%3EMy%20User%20-%20User%201%22%20'Forbidden'%20%3C%2FSTRONG%3E(%22message%5C%22%3A%5C%22The%20bot%20is%20not%20part%20of%20the%20conversation%20roster.%5C%22)%3C%2FP%3E%3CP%3E-%20%22My%20User%20-%20User%202%22%20%3CSTRONG%3Eworks%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E1)%20What's%20the%20reason%3F%20Are%20there%20any%20limitations%3F%26nbsp%3B%3C%2FP%3E%3CP%3E2)%20Maybe%20there%20is%20additional%20way%20to%20get%20%22my%22%20account%20(email%20address%20%2C%20domain%20name)%3F%3C%2FP%3E%3CP%3E3)%20Are%20there%20any%20ways%20to%20put%20into%20cach%20the%20current%20user%20(loged%20in%20Teams)%20email%20address%3F%3C%2FP%3E%3CP%3EI%20need%20to%20know%20the%20email%20address%20(domain%20name)%20in%20each%20action%20(activity).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2938348%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EChat%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2938818%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Team.%20Bot.%20TeamsInfo.GetMemberAsync%20returns%20'Forbidden'%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2938818%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1182850%22%20target%3D%22_blank%22%3E%40Paul_By%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20share%20sample%20details%20which%20you%20are%20referring.It%20helps%20us%20to%20repro%20the%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2939233%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Team.%20Bot.%20TeamsInfo.GetMemberAsync%20returns%20'Forbidden'%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2939233%22%20slang%3D%22en-US%22%3EWorkaround%3A%20I%20get%20'TeamsChannelAccount'%20data%20(TeamsInfo.GetMemberAsync(...))%20in%20%22Bot-User%22%20conversation%20(first%20step)%20and%20put%20it%20into%20'UserState'.%20Then%20I%20can%20get%20and%20use%20it.%3CBR%20%2F%3EMy%20Bot%3A%20%22scopes%22%3A%20%5B%22personal%22%5D.%20Maybe%20this%20is%20the%20reason%20of%20the%20issue.%3C%2FLINGO-BODY%3E
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.

best response confirmed by ChetanSharma-msft (Microsoft)
Solution
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.
We support Ukraine and condemn war. Push Russian government to act against war. Be brave, vocal and show your support to Ukraine. Follow the latest news HERE