gpt4 book ai didi

microsoft-teams - 微软流量自适应卡片在团队中提及团队用户

转载 作者:行者123 更新时间:2023-12-01 06:49:28 26 4
gpt4 key购买 nike

我正在创建一个 Microsoft 流程,以在团队内的 Flow 机器人发布的自适应卡片中提及用户。

这是我尝试使用的操作
PostAdaptiveCardAsFlowBot

这是我的 JSON 的简化版本,用于执行此操作

{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"color": "Attention",
"text": "Hey!"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "<at>steve@example.com</at>",
}
],
"width": "stretch"
}
]
}
]
},
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Teams Message",
"url": "-teamsUrl-"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}

不幸的是,这仅显示为 <at>steve@example.com</at>
如果我使用与团队 channel 消息相同的语法,那么用户将被提及。

PostMessageAsFlowBot

是否可以通过这种方式在自适应卡片中提及用户?

最佳答案

但是,仅从 1.2 版开始,提及才适用于 Adaptive Card。
官方文档:Mention support within Adaptive cards v1.2

{
"version":"1.2",
"type":"AdaptiveCard",
"body":[
{
"type":"TextBlock",
"text":"Ahoj <at>Michal Macejko</at>",
"wrap":True
}
],
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"msteams":{
"entities":[
{
"additional_properties": {},
"text": "<at>Michal Macejko</at>",
"type": "mention",
"mentioned":
{
"additional_properties": {},
"id": "channelAccountID",
"name": "Michal Macejko",
"aad_object_id": "userID"
}
}
]
}
}
aad_object_iduserId属性,取自 https://graph.microsoft.com/v1.0/teams/#{team_id}/members channelAccountID是您应该从 SDK 获取的值 get_conversation_member
这是一个python示例:
from botbuilder.schema import Activity, ActivityTypes, Attachment, Mention
from pyadaptivecards.card import AdaptiveCard
from pyadaptivecards.components import TextBlock

connector_client = await ADAPTER.create_connector_client(service_url)
text_block = TextBlock(text="Hey! <at>Michal Macejko<at>", wrap=True)
entities = []
channel_account = await connector_client.conversations.get_conversation_member(conversation_id=teams_channel_id, member_id=aad_object_id)
mention_object = Mention(mentioned=channel_account, text="<at>Michal Macejko</at>", type='mention')
entities.append(Mention().deserialize(mention_object.serialize()))

card = AdaptiveCard(body=[text_block])
card.version = '1.2'
card_hash = card.to_dict()
card_hash['msteams'] = { 'entities': entities }

attachment = Attachment(content_type='application/vnd.microsoft.card.adaptive', content=card_hash)
message = Activity(type=ActivityTypes.message, attachments=[attachment])
await connector_client.conversations.send_to_conversation(teams_channel_id, message)

关于microsoft-teams - 微软流量自适应卡片在团队中提及团队用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56437390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com