botframeworkmicrosoft-teamsmicrosoft-graph-teamsbot-framework-composer

Get Teams Graph API id from bot framework request


Bot framework .Activity.TeamsGetTeamInfo().Id Docs gives Ids in the format of 19:pmwblabla-DU6Cjf25Fblablabla@thread.tacv2, but Graph API takes Ids in the form of GUIDs 1be44bc0-02cb-4715-9ecc-cba191e64cb5 Docs.

Graph API will return the "InternalId" which matches the Bot Framework, but how do I get the GUID from the Bot framework request?

I just want to do simple stuff like invite people to a team, create/delete teams/channels.

The Request to the server does not include the info, so DialogContext.Activity.TeamsGetTeamInfo().AadGroupId is useless:

{
    "text": "<at>TestBot</at> help\n",
    "textFormat": "plain",
    "attachments": [
        {
            "contentType": "text/html",
            "content": "<div><div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">TestBot</span> help</div>\n</div>"
        }
    ],
    "type": "message",
    "timestamp": "2022-05-26T06:33:49.1002055Z",
    "localTimestamp": "2022-05-26T13:33:49.1002055+07:00",
    "id": "165354145676828864",
    "channelId": "msteams",
    "serviceUrl": "https://smba.trafficmanager.net/emea/",
    "from": {
        "id": "29:1d9mrAWL8cZKs3gp4Pasd8WD771EhsE1tlCs_MQn1Rb5QTmzk71GK934z8sxyHBE0eRFhWf-YslJXt_HdNDag",
        "name": "MyName",
        "aadObjectId": "guid-guid-guid-guid-guid"
    },
    "conversation": {
        "isGroup": true,
        "conversationType": "channel",
        "tenantId": "guid-guid-guid-guid-guid",
        "id": "19:eZWOxzVhYnXQasd07VtQVpdAHkgfP-7JyvcJR-0_w1@thread.tacv2;messageid=1653026739856"
    },
    "recipient": {
        "id": "28:guid-guid-guid-guid-guid",
        "name": "TestMyBot2343456345656367"
    },
    "entities": [
        {
            "mentioned": {
                "id": "28:guid-guid-guid-guid-guid",
                "name": "TestBot"
            },
            "text": "<at>TestBot</at>",
            "type": "mention"
        },
        {
            "locale": "en-US",
            "country": "US",
            "platform": "Windows",
            "timezone": "here",
            "type": "clientInfo"
        }
    ],
    "channelData": {
        "teamsChannelId": "19:eZWOxzasdasdasdHkgfP-7JyvcJR-0_w1@thread.tacv2",
        "teamsTeamId": "19:eZWOxzasdasdasdHkgfP-7JyvcJR-0_w1@thread.tacv2",
        "channel": {
            "id": "19:eZWOxzasdasdasdHkgfP-7JyvcJR-0_w1@thread.tacv2"
        },
        "team": {
            "id": "19:eZWOxzasdasdasdHkgfP-7JyvcJR-0_w1@thread.tacv2"
        },
        "tenant": {
            "id": "guid-guid-guid-guid-guid"
        }
    },
    "locale": "en-US",
    "localTimezone": "here"
}

Solution

  • It seems DialogContext.Activity.TeamsGetTeamInfo() only returns the information given from the payload, and the default from Teams is to NOT include the AadGroupId.

    There is however an 'active' version of the same await TeamsInfo.GetTeamDetailsAsync(dc.Context). This will return the full object.