Search code examples
microsoft-graph-apimicrosoft-teamsmicrosoft-graph-teams

graph-api: Adaptive card with mention doesn't render date properly


It seams that msteams object doesn't allow to render date, when card pushed through graph api in private msteams channel.

Example is like this:

POST https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/messages
{
  "body": {
        "contentType": "html",
        "content": "<attachment id=\"1\"/>"
  },
    "attachments":[
        {
            "contentType":"application/vnd.microsoft.card.adaptive",
            "id":"1",
            "content":"{\"type\":\"AdaptiveCard\",\"body\":[{\"text\":\"<at>Lev</at> hello {{ DATE(2021-04-28T00:00:00Z, SHORT) }}\",\"wrap\":true,\"type\":\"TextBlock\"}],\"version\":\"1.3\",\"msteams\":{\"entities\":[{\"type\":\"mention\",\"text\":\"<at>Lev</at>\",\"mentioned\":{\"id\":\"29:131...Rg\",\"name\":\"Lev\"}}]}}"
        }
    ]
}

Example in teams

Is there some workaround?


Solution

  • msteams object is not allowed through Graph API. Only Bots have access to the msteams object. This is by design. The at mention object when you send from bot, the user will get notify in teams activity and the card will display as shown in below image

    enter image description here

    and the at mention in adaptive card using graph api post request, the user will not get notify in teams activity and the card will display as shown in below image enter image description here