使用 Microsoft Teams 和 Action.Submit 时如何知道按下了哪个 Adaptive Card 按钮
How to know which Adaptive Card button is pressed when using Microsoft Teams and Action.Submit
我使用 Microsoft Bot Framework Composer 创建了一个机器人并显示了以下自适应卡片。使用 Action.Submit 和 Task/Fetch 提交消息时,如何确定按下了哪个按钮?
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Publish Adaptive Card Schema"
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate"
},
{
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "task/fetch",
"value": {
"option": "opt1"
}
}
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "https://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
我的机器人正确接收了提交的消息,但我无法分辨按下了哪个按钮。下面是this.activity发送的例子。我可以看到 msteams 类型设置为 task/fetch,但无法判断在上面的卡片中按下了哪个按钮。
{
"type": "invoke",
"id": "",
"timestamp": "2021-06-29T16:57:27.551-05:00",
"localTimestamp": "2021-06-29T16:57:27.551-05:00",
"localTimezone": "America/Chicago",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"channelId": "msteams",
"from": {
"id": "",
"name": "Mike",
"aadObjectId": ""
},
"conversation": {
"conversationType": "personal",
"id": "",
"tenantId": ""
},
"recipient": {
"id": "",
"name": "csharpdemo"
},
"locale": "en-US",
"entities": [
{
"type": "clientInfo",
"locale": "en-US",
"country": "US",
"platform": "Windows",
"timezone": "America/Chicago"
}
],
"channelData": {
"tenant": {
"id": ""
},
"source": {
"name": "compose"
},
"legacy": {
"replyToId": ""
}
},
"replyToId": "",
"value": {
"data": {
"type": "task/fetch"
},
"context": {
"theme": "default"
}
},
"name": "task/fetch",
"callerId": "urn:botframework:azure"
}
看来我需要在 msteams 节点中传递值或数据字段,但不确定如何传递。
https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/
如果需要,您可以在数据对象中包含其他隐藏属性。
{
"type": "Action.Submit",
"title": "submit",
"data": {
"msteams": {
"type": "task/fetch"
},
"Value1": "some value"
}
}
我使用 Microsoft Bot Framework Composer 创建了一个机器人并显示了以下自适应卡片。使用 Action.Submit 和 Task/Fetch 提交消息时,如何确定按下了哪个按钮?
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Publish Adaptive Card Schema"
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate"
},
{
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "task/fetch",
"value": {
"option": "opt1"
}
}
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "https://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
我的机器人正确接收了提交的消息,但我无法分辨按下了哪个按钮。下面是this.activity发送的例子。我可以看到 msteams 类型设置为 task/fetch,但无法判断在上面的卡片中按下了哪个按钮。
{
"type": "invoke",
"id": "",
"timestamp": "2021-06-29T16:57:27.551-05:00",
"localTimestamp": "2021-06-29T16:57:27.551-05:00",
"localTimezone": "America/Chicago",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"channelId": "msteams",
"from": {
"id": "",
"name": "Mike",
"aadObjectId": ""
},
"conversation": {
"conversationType": "personal",
"id": "",
"tenantId": ""
},
"recipient": {
"id": "",
"name": "csharpdemo"
},
"locale": "en-US",
"entities": [
{
"type": "clientInfo",
"locale": "en-US",
"country": "US",
"platform": "Windows",
"timezone": "America/Chicago"
}
],
"channelData": {
"tenant": {
"id": ""
},
"source": {
"name": "compose"
},
"legacy": {
"replyToId": ""
}
},
"replyToId": "",
"value": {
"data": {
"type": "task/fetch"
},
"context": {
"theme": "default"
}
},
"name": "task/fetch",
"callerId": "urn:botframework:azure"
}
看来我需要在 msteams 节点中传递值或数据字段,但不确定如何传递。
https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/
如果需要,您可以在数据对象中包含其他隐藏属性。
{
"type": "Action.Submit",
"title": "submit",
"data": {
"msteams": {
"type": "task/fetch"
},
"Value1": "some value"
}
}