图-api:带有提及的自适应卡片无法正确呈现日期

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

当卡片私下通过 graph api 时,msteams 对象不允许渲染日期msteams 频道。

例子是这样的:

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

有什么解决方法吗?

请检查以下请求正文

{
    "body": {
        "contentType": "html",
        "content": "<attachment id=\"1\"/>"
    },
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "id": "1",
            "content": "{    \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",    \"type\": \"AdaptiveCard\",    \"version\": \"1.0\",    \"body\": [        {            \"type\": \"TextBlock\",            \"text\": \"Your package will arrive on {{DATE(2017-02-14T06:00:00Z, SHORT)}} at {{TIME(2017-02-14T06:00:00Z)}}\",            \"wrap\": true        }    ]}"
        }
    ]
}

msteams 对象不允许通过图表 API。只有机器人可以访问 msteams 对象。这是设计使然。 当您从 bot 发送时提及对象,用户将在团队 activity 中收到通知并且卡片将如下图所示显示

和使用图形 api post 请求的自适应卡片中的 at mention,用户将不会在团队 activity 中收到通知,卡片将显示如下图所示