gpt4 book ai didi

node.js - 自适应卡上的 Action.Submit 不会调用下一步(仅在 Microsoft Teams 中不起作用,在网络聊天中起作用): Bot Framework V4

转载 作者:太空宇宙 更新时间:2023-11-04 01:23:57 25 4
gpt4 key购买 nike

在 Microsoft bot 框架 SDK V4 的自适应卡中使用 Action.Submit 时,不会调用 waterfall 对话框流中的后续步骤(仅当与 Microsoft 团队集成时)

这是Microsoft框架SDK v4中的nodejs代码。仅当与 Microsoft 团队集成时才会出现此问题。

我已经在网络聊天和聊天模拟器中尝试过这个。 Action.Submit 正在调用 waterfall 对话框流的后续步骤。

** 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 基类中的 onMessage 方法。

界面看起来像 The Adaptive Card for ratings

最佳答案

Teams 似乎不能很好地处理字符串提交操作。我不知道这是一个新问题还是一直都是这样。尝试将提交操作数据设置为对象而不是字符串:

"selectAction": {
"type": "Action.Submit",
"data": {
"rating": "bad"
}
}

这将生成一条无文本消息,因此您需要从事件的 value 属性中提取评级。请参阅this post有关将字符串从事件的值属性传输到其文本属性的说明。请参阅my latest blog post了解有关将自适应卡与 Bot 框架结合使用的更多信息。

编辑:我发现您可以使用 this document 中的格式在 Teams 中模拟 imBack :

{
"type": "Action.Submit",
"title": "Click me for imBack",
"data": {
"msteams": {
"type": "imBack",
"value": "Text to reply in chat"
}
}
}

关于node.js - 自适应卡上的 Action.Submit 不会调用下一步(仅在 Microsoft Teams 中不起作用,在网络聊天中起作用): Bot Framework V4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58220945/

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