TeamsActivityHandler OnTeamsCardActionInvokeAsync 未触发卡片提交操作
TeamsActivityHandler OnTeamsCardActionInvokeAsync is not firing on Card Submit Action
我有一个简单的自适应卡片,带有几个输入字段和一个带有提交操作的操作按钮。
var card = new AdaptiveCard("1.0")
{
Body = new List<AdaptiveElement>()
{
new AdaptiveTextBlock()
{
Text = "Title",
Separator = true
},
new AdaptiveTextBlock()
{
Text = "Product Line"
},
new AdaptiveChoiceSetInput()
{
Id = "cmbProductLine",
Choices = new List<AdaptiveChoice>()
{
new AdaptiveChoice() {
Title = "Choice 1",
Value = "1"},
new AdaptiveChoice() {
Title = "Choice 2",
Value = "2"}
},
Style = AdaptiveChoiceInputStyle.Compact
},
new AdaptiveTextBlock()
{
Text = "Organization"
},
new AdaptiveTextInput()
{
Id = "txtOrgName",
Placeholder = "Name"
},
},
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title = "Save",
DataJson = @"{'Action':'Save'}"
}
}
};
现在单击“保存操作”按钮后,我希望触发 OnTeamsCardActionInvokeAsync 事件,因为我的机器人继承自 TeamsActivityHandler。但是按钮只触发 OnMessageActivityAsync 事件。这是 Bot 框架中的错误还是我遗漏了什么?
这是根据此代码创建的 JSON。
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Please provide organization details to proceed:",
"separator": true
},
{
"type": "TextBlock",
"text": "Organization"
},
{
"type": "Input.Text",
"id": "txtOrgName",
"placeholder": "Organization Name",
"style": "email"
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"Action": "OrgName",
"msteams": {
"type": "task/fetch"
},
"data": "Invoke"
},
"title": "Save Configuration"
},
{
"type": "Action.Submit",
"data": {
"Action": "Cancel"
},
"title": "Cancel"
}
]
}
在 msteams 对象中包含带有自适应卡片的调用操作包含数据对象。您能否查看 this 文档以获取更多信息?
示例:自适应卡 JSON :
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Adaptive card"
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"msteams": {
"type": "task/fetch"
},
"data": "Invoke"
},
"title": "Invoke"
}
]
}
我有一个简单的自适应卡片,带有几个输入字段和一个带有提交操作的操作按钮。
var card = new AdaptiveCard("1.0")
{
Body = new List<AdaptiveElement>()
{
new AdaptiveTextBlock()
{
Text = "Title",
Separator = true
},
new AdaptiveTextBlock()
{
Text = "Product Line"
},
new AdaptiveChoiceSetInput()
{
Id = "cmbProductLine",
Choices = new List<AdaptiveChoice>()
{
new AdaptiveChoice() {
Title = "Choice 1",
Value = "1"},
new AdaptiveChoice() {
Title = "Choice 2",
Value = "2"}
},
Style = AdaptiveChoiceInputStyle.Compact
},
new AdaptiveTextBlock()
{
Text = "Organization"
},
new AdaptiveTextInput()
{
Id = "txtOrgName",
Placeholder = "Name"
},
},
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title = "Save",
DataJson = @"{'Action':'Save'}"
}
}
};
现在单击“保存操作”按钮后,我希望触发 OnTeamsCardActionInvokeAsync 事件,因为我的机器人继承自 TeamsActivityHandler。但是按钮只触发 OnMessageActivityAsync 事件。这是 Bot 框架中的错误还是我遗漏了什么?
这是根据此代码创建的 JSON。
{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Please provide organization details to proceed:",
"separator": true
},
{
"type": "TextBlock",
"text": "Organization"
},
{
"type": "Input.Text",
"id": "txtOrgName",
"placeholder": "Organization Name",
"style": "email"
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"Action": "OrgName",
"msteams": {
"type": "task/fetch"
},
"data": "Invoke"
},
"title": "Save Configuration"
},
{
"type": "Action.Submit",
"data": {
"Action": "Cancel"
},
"title": "Cancel"
}
]
}
在 msteams 对象中包含带有自适应卡片的调用操作包含数据对象。您能否查看 this 文档以获取更多信息?
示例:自适应卡 JSON :
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Adaptive card"
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"msteams": {
"type": "task/fetch"
},
"data": "Invoke"
},
"title": "Invoke"
}
]
}