如何从 node.js 中的自适应卡读取按钮操作?
How can I read button action from an Adaptive Card in node.js?
如果我有如下适配卡:
var msg = new builder.Message(session)
.addAttachment({
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
speak: "<s>Your meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
body: [
{
"type": "TextBlock",
"text": "Adaptive Card design session",
"size": "large",
"weight": "bolder"
},
{
"type": "TextBlock",
"text": "Conf Room 112/3377 (10)"
},
{
"type": "TextBlock",
"text": "12:30 PM - 1:30 PM"
},
{
"type": "TextBlock",
"text": "Snooze for"
},
{
"type": "Input.ChoiceSet",
"id": "snooze",
"style":"compact",
"choices": [
{
"title": "5 minutes",
"value": "5",
"isSelected": true
},
{
"title": "15 minutes",
"value": "15"
},
{
"title": "30 minutes",
"value": "30"
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Snooze"
},
{
"type": "Action.Submit",
"title": "I'll be late"
}
]
}
});
我如何在对话中展示它,以便机器人等待用户单击其中一个提交按钮?
我如何读取按下的按钮?
我在 node.js 中找不到任何示例。
非常感谢
您需要检查 session.message.value
是否存在
if (session.message && session.message.value) {
// process your card's submit action
}
查看以下内容Adaptive Card sample,了解您如何处理提交操作。
如果我有如下适配卡:
var msg = new builder.Message(session)
.addAttachment({
contentType: "application/vnd.microsoft.card.adaptive",
content: {
type: "AdaptiveCard",
speak: "<s>Your meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
body: [
{
"type": "TextBlock",
"text": "Adaptive Card design session",
"size": "large",
"weight": "bolder"
},
{
"type": "TextBlock",
"text": "Conf Room 112/3377 (10)"
},
{
"type": "TextBlock",
"text": "12:30 PM - 1:30 PM"
},
{
"type": "TextBlock",
"text": "Snooze for"
},
{
"type": "Input.ChoiceSet",
"id": "snooze",
"style":"compact",
"choices": [
{
"title": "5 minutes",
"value": "5",
"isSelected": true
},
{
"title": "15 minutes",
"value": "15"
},
{
"title": "30 minutes",
"value": "30"
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Snooze"
},
{
"type": "Action.Submit",
"title": "I'll be late"
}
]
}
});
我如何在对话中展示它,以便机器人等待用户单击其中一个提交按钮?
我如何读取按下的按钮?
我在 node.js 中找不到任何示例。
非常感谢
您需要检查 session.message.value
是否存在
if (session.message && session.message.value) {
// process your card's submit action
}
查看以下内容Adaptive Card sample,了解您如何处理提交操作。