不能在使用Teams PowerShell模块时提到Adaptive Card中的人



我已经在我的一个团队频道中注册了一个传入消息Webhook。我正在使用Microsoft Teams PowerShell创建一个自适应卡并将其发送到一个通道:

$SimpleCard = @{
type = "message";
attachments = @(@{
contentType  = 'application/vnd.microsoft.card.adaptive';
contentUrl = $null;
content = @{
'$schema' = 'http://adaptivecards.io/schemas/adaptive-card.json';
type = 'AdaptiveCard';
version = '1.2';
body = @(@{
type = 'TextBlock';
text = "Hello <at>andrea.tino@mycompany.com</at>";
})
}
});
msteams = @{
entities = @(@{
type = 'mention';
text = "<at>andrea.tino@mycompany.com</at>";
mentioned = @{
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
name = 'Andrea Tino';
}
})
}
}
Invoke-RestMethod -Method post
-ContentType 'Application/Json'
-Body ($SimpleCard | ConvertTo-Json -Depth 10)
-Uri "https://myorg.webhook.office.com/webhookb2/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/IncomingWebhook/xxxxxxxx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

卡片正确发送,但提述没有正确呈现。

错误ID吗?

值得一提的是,文档显式引用了一种类型的User ID:

{
"type": "mention",
"text": "<at>John Doe</at>",
"mentioned": {
"id": "29:123124124124",
"name": "John Doe"
}
}

您可以看到示例中的ID是:"id": "29:123124124124",而我的ID是GUID。我通过Get-TeamUser检索了该用户ID。

我做错了什么?

仅在bot上下文中支持在adaptive card中提及,获取id的可用方法在文档中列出- Mention -support-within- adaptivescards -v12

相关团队正在努力支持用户在传入Webhook中使用AAD对象Id和UPN(使用图形API)。

ID和Name可以从活动中获取,如下所示

from: {
id: '29:15fREhoUuf6vVCOuaJYVH-AB6QXXX',
name: 'MOD Administrator',
aadObjectId: 'XXXX'
}

提供一个参考,这将有助于- mention-support-within-adaptive-cards-v12

最新更新