Node.js can';t到达json文件中的节
我正在尝试检索Node.js can';t到达json文件中的节,node.js,botframework,adaptive-cards,Node.js,Botframework,Adaptive Cards,我正在尝试检索json文件的自适应卡中的选择。 因此,当选择“花生”选项时,我想将其分配给一个变量。但是代码不断抛出错误 自适应卡代码: { "type": "message", "speak": "...", "attachments": [ { "contentType": "application/vnd.microsoft.card.adaptive", "content": {
json
文件的自适应卡中的选择。
因此,当选择“花生”选项时,我想将其分配给一个变量。但是代码不断抛出错误
自适应卡代码:
{
"type": "message",
"speak": "...",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Almost there...",
"size": "large",
"weight": "bolder"
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Beef",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "What are you allergic to?",
"size": "medium",
"wrap": true
},
{
"type": "Input.ChoiceSet",
"value": "BeefAllergy",
"id": "BeefAllergy",
"style": "expanded",
"isMultiSelect": false,
"isCompact": false,
"choices": [
{
"title": "Peanut",
"value": "peanut"
},
{
"title": "Seafood",
"value": "seafood"
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Next",
"data": {
"mealOptions": "beef"
}
}
]
}
}
]
}
}
]
}
以下是我如何将其存储在变量中:
lunchAllergy= session.message.attachments.content.actions.card.body[1].choices[1].value
session.send(lunchallergy)
下面是错误:
错误:无法读取未定义的属性“actions”
在我对自适应卡内容的测试中,实际上,当用户单击
操作.Submit
按钮时,您的bot可以在会话.message.value
中获得用户选择,并且您可以在变量中存储所需内容
有关详细信息,您可以参考上的示例。在c#中,但它可能会对您有所帮助,因为它使用JSON自适应卡。它有一张卡片做着几乎完全相同的事情。