无法使用 Teams PowerShell 模块在 Adaptive Card 中提及人员
Cannot mention person in Adaptive Card using Teams PowerShell Module
我已经在我的一个 Teams 频道中注册了 Incoming Messages 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 错误?
值得一提的是,the doc明确引用了一种用户ID:
{
"type": "mention",
"text": "<at>John Doe</at>",
"mentioned": {
"id": "29:123124124124",
"name": "John Doe"
}
}
可以看到例子中的ID是:"id": "29:123124124124"
而我的是GUID。我通过 Get-TeamUser
.
检索了该用户 ID
我做错了什么?
ID 和 Name 可以从 activity 中获取,如下所示
from: {
id: '29:15fREhoUuf6vVCOuaJYVH-AB6QXXX',
name: 'MOD Administrator',
aadObjectId: 'XXXX'
}
提供一个有帮助的参考 - mention-support-within-adaptive-cards-v12
仅在机器人上下文中支持在自适应卡片中提及,文档中列出了获取 ID 的可用方法 - mention-support-within-adaptive-cards-v12
相关团队正在努力支持在传入 Webhook 中使用 AAD 对象 ID 和 UPN(使用图形 API)来提及用户。
我已经在我的一个 Teams 频道中注册了 Incoming Messages 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 错误?
值得一提的是,the doc明确引用了一种用户ID:
{
"type": "mention",
"text": "<at>John Doe</at>",
"mentioned": {
"id": "29:123124124124",
"name": "John Doe"
}
}
可以看到例子中的ID是:"id": "29:123124124124"
而我的是GUID。我通过 Get-TeamUser
.
我做错了什么?
ID 和 Name 可以从 activity 中获取,如下所示
from: {
id: '29:15fREhoUuf6vVCOuaJYVH-AB6QXXX',
name: 'MOD Administrator',
aadObjectId: 'XXXX'
}
提供一个有帮助的参考 - mention-support-within-adaptive-cards-v12
仅在机器人上下文中支持在自适应卡片中提及,文档中列出了获取 ID 的可用方法 - mention-support-within-adaptive-cards-v12
相关团队正在努力支持在传入 Webhook 中使用 AAD 对象 ID 和 UPN(使用图形 API)来提及用户。