Search code examples
botframeworkmicrosoft-teams

Teams Botbuilder, Why do i receive a blank conversation addObjectId?


We have a published app and we are working on new functionality that requires users' and conversations' aadObjectId. When we're receiving a message on the Bot's side we see conversation.aadObjectId == null. I've tried to add RSC permissions but it didn't help. Anyone had the same and what should i do to get aadObjetcID? Here's an example of my conversation data:

....
"serviceUrl": "https://smba.trafficmanager.net/emea/",
"conversation": {
    "id": "a:1Cohygr ... trunkated ... TscZ",
    "tenantId": "5df90000-0000-0000-0000-00000000c656",
    "conversationType": "personal",
    "aadObjectId": null  # WHY IS THIS NULL ?
}
....

Any help would be much appreciated.


Solution

  • In our app we needed conversation aad_object_id to get all recipients and then get their email addresses to send notification to them. I've made a workaround using this API:

        if turn_context.activity.channel_id == Channels.ms_teams:
            team_details = await TeamsInfo.get_team_details(turn_context)
    
            await turn_context.send_activity(
                f"the team aad_object_id: {team_details.aad_group_id}"
            )
    

    Then you can request members from Graph:

    /v1.0/groups/{team_details.aad_group_id}/members
    

    If you need an email address of the user from direct conversation, you should use this request:

    /v1.0/users/{user.aad_object_id}
    

    I hope this will save you some time as i spent days on this and useless responses on stackoverflow regarding this.