MS Teams Get Roster returns "The bot is not part of the conversation roster."
P

2

5

I am trying to fetch the MS Teams roaster / user profile. Below are the sequence of Postman calls I am making:

Generated Access Token: https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token

Generated User Access Token: https://login.microsoftonline.com/{{TenantId}}/oauth2/v2.0/token Get

My Joined Team: https://graph.microsoft.com/v1.0/me/joinedTeams

Get Internal Team Id:https://graph.microsoft.com/v1.0/teams/{{TeamId}}/channels

Fetch Roster/user profile:https://{{ServiceUrl}}/v3/conversations/{{tId}}/members/

Everything was working fine, but today I am getting 403 forbidden error

{
    "error": {
        "code": "BotNotInConversationRoster",
        "message": "The bot is not part of the conversation roster."
    }
}

Please note that I am able to communicate with the bot.

Below are the permissions that I have provided for delegate and application Directory.Read.All Group.Read.All Group.ReadWrite.All User.Read User.Read.All User.ReadBasic.All

Any suggestions to fix the same?

Poker answered 7/3, 2020 at 16:46 Comment(0)
A
4

Notice that your last call, the one to "serviceurl", is NOT part of the Graph, obviously. As a result, it's authentication is different. In this case, Teams is authenticating it as a bot, and it needs certain rights. For instance, the bot MUST be installed to the Team in question in order to get the roster for that Team. You say it was working before - is that in the same Team? If not, the bot needs to be added to that Team. If "yes", then perhaps the bot was removed from the Team by someone?

Austriahungary answered 7/3, 2020 at 17:53 Comment(13)
The bot is already added to the team, like this learn.microsoft.com/en-us/azure/bot-service/…. Can you please tell about rights?Poker
ah I see - what you've sent is what's called the "Channels" registration. It's TOTALLY different from a "Channel" inside a Teams. This "Channels" in your screenshot means "what KIND of platform can my bot speak with (e.g. Teams, Slack, Facebook). Once that's done, you still need the bot registered into (a) your tenant and (b) particular Teams. It sounds like you've done that part, maybe with App Studio?Austriahungary
You can use Graph to install your bot: learn.microsoft.com/en-us/graph/…Marguritemargy
@AndrewClear the bot is already able to communicate. I am getting the response from the bot.Poker
@HiltonGiesenow I am able to communicate to the bot via webhooks. (i didnot use app studio)Poker
great! Are you able to get the roster?Austriahungary
@HiltonGiesenow sorry i mean to say that the bot is already part of them since i am able to communicate to the bot. But https://{{ServiceUrl}}/v3/conversations/{{ChannelId}}/members/ throws 403Poker
To make a Bot part of the conversation in channel you need to @mention Bot, Could you try to pass conversation id instead of team id?Roanna
@Roanna I am SORRY, i could not understand what you meant. I am getting value from graph.microsoft.com/v1.0/teams{{TeamId}}/channels call. I am using this id to pass it to https://{{ServiceUrl}}/v3/conversations/{{ChannelId}}/members/Poker
{ "@odata.context": "graph.microsoft.com/v1.0/…", "@odata.count": 1, "value": [ { "id": "19:[email protected]", "displayName": "General", "description": "rdh-team-7march", "email": "", "webUrl": "teams.microsoft.com/l/channel/…" } ] }Poker
You need to generate accessToken first than call the https://{{ServiceUrl}}/v3/conversations/{{conversationID}}/members/ API it should work, Please take a look at fetching roster using REST API Let me know if this doesn't help youRoanna
@RDX, are you happy to close this out, now that it's working?Austriahungary
@HiltonGiesenow Thank-you so much for your timely help on this. I was able to fetch the roster details!!Poker
M
2

You must install your bot as an app in a team before you can call this API. Sending it messages via a webhook does not count. It must be an app installed in the team. Because the bot is retrieving personal information, it needs to be added to that context before the API will work.

See:

Marguritemargy answered 10/3, 2020 at 17:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.