Action.Submit 自适应卡片不调用下一步(不只在 Microsoft Teams 中工作在网络聊天中工作):Bot Framework V4
Action.Submit on Adaptive cards is not calling the next step (not working only in Microsoft Teams works in web chat) : Bot Framework V4
在 Microsoft bot 框架 SDK V4 的自适应卡片中使用 Action.Submit 时,不会调用瀑布对话流中的后续步骤(仅当与 Microsoft 团队集成时)
这是微软框架SDK v4中的nodejs代码。仅在与 Microsoft 团队集成时存在此问题。
我已经在网络聊天和聊天模拟器中尝试过了。 Action.Submit 正在调用瀑布对话流的后续步骤。
** NodeJS 中的机器人代码 **
async endConversation(stepContext){
console.log("on endConversation")
await stepContext.context.sendActivity({
attachments: [CardFactory.adaptiveCard(RatingCard)]
});
return await stepContext.prompt(TEXT_PROMPT, { prompt: '' });
}
async feedback(stepContext){
console.log("on feedback == "+stepContext.result)
}
**自适应卡json**
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "medium",
"weight": "bolder",
"color": "accent",
"text": "Rate your experience!"
},
{
"type": "TextBlock",
"separator": true,
"text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
"wrap": true
},
{
"type": "ColumnSet",
"spacing": "Medium",
"columns": [
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "bad"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Bad"
}
],
"width": "auto"
},
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "ok"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Ok"
}
],
"width": "auto"
},
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "good"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Good"
}
],
"width": "auto"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
预期:
异步方法反馈是流程的下一步,当用户点击自适应卡片中的星形图像时应该调用它。
实际:
下一步没有被调用。但是它会转到 ActivityHandler base class.
中的 onMessage 方法
界面看起来像
Teams 似乎没有很好地处理字符串提交操作。我不知道这是一个新问题,还是一直都是这样。尝试使您的提交操作数据成为对象而不是字符串:
"selectAction": {
"type": "Action.Submit",
"data": {
"rating": "bad"
}
}
这将生成一条无文本消息,因此您需要从 activity 的值 属性 中提取评分。有关将自适应卡片与 Bot Framework 结合使用的详细信息,请参阅 this post for instructions on transferring a string from an activity's value property to its text property. See my latest blog post。
编辑:我发现您可以使用 this document:
中的格式在 Teams 中模拟 imBack
{
"type": "Action.Submit",
"title": "Click me for imBack",
"data": {
"msteams": {
"type": "imBack",
"value": "Text to reply in chat"
}
}
}
在 Microsoft bot 框架 SDK V4 的自适应卡片中使用 Action.Submit 时,不会调用瀑布对话流中的后续步骤(仅当与 Microsoft 团队集成时)
这是微软框架SDK v4中的nodejs代码。仅在与 Microsoft 团队集成时存在此问题。
我已经在网络聊天和聊天模拟器中尝试过了。 Action.Submit 正在调用瀑布对话流的后续步骤。
** NodeJS 中的机器人代码 **
async endConversation(stepContext){
console.log("on endConversation")
await stepContext.context.sendActivity({
attachments: [CardFactory.adaptiveCard(RatingCard)]
});
return await stepContext.prompt(TEXT_PROMPT, { prompt: '' });
}
async feedback(stepContext){
console.log("on feedback == "+stepContext.result)
}
**自适应卡json**
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "medium",
"weight": "bolder",
"color": "accent",
"text": "Rate your experience!"
},
{
"type": "TextBlock",
"separator": true,
"text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
"wrap": true
},
{
"type": "ColumnSet",
"spacing": "Medium",
"columns": [
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "bad"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Bad"
}
],
"width": "auto"
},
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "ok"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Ok"
}
],
"width": "auto"
},
{
"type": "Column",
"selectAction": {
"type": "Action.Submit",
"data": "good"
},
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
"size": "auto"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"text": "Good"
}
],
"width": "auto"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
预期:
异步方法反馈是流程的下一步,当用户点击自适应卡片中的星形图像时应该调用它。
实际:
下一步没有被调用。但是它会转到 ActivityHandler base class.
中的 onMessage 方法界面看起来像
Teams 似乎没有很好地处理字符串提交操作。我不知道这是一个新问题,还是一直都是这样。尝试使您的提交操作数据成为对象而不是字符串:
"selectAction": {
"type": "Action.Submit",
"data": {
"rating": "bad"
}
}
这将生成一条无文本消息,因此您需要从 activity 的值 属性 中提取评分。有关将自适应卡片与 Bot Framework 结合使用的详细信息,请参阅 this post for instructions on transferring a string from an activity's value property to its text property. See my latest blog post。
编辑:我发现您可以使用 this document:
中的格式在 Teams 中模拟imBack
{
"type": "Action.Submit",
"title": "Click me for imBack",
"data": {
"msteams": {
"type": "imBack",
"value": "Text to reply in chat"
}
}
}