【问题标题】:Get variable from Adaptive card `Action.Submit` in Botframework从 Botframework 中的自适应卡片“Action.Submit”获取变量
【发布时间】:2019-07-11 18:30:57
【问题描述】:

当用户点击按钮时如何获取值?我有这张示例卡。

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  "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)",
      "isSubtle":true
    },
    {
      "type": "TextBlock",
      "text": "12:30 PM - 1:30 PM",
      "isSubtle":true,
      "spacing":"none"
    },
    {
      "type": "TextBlock",
      "text": "Snooze for"
    },
    {
      "type": "Input.ChoiceSet",
      "id": "snooze",
      "style":"compact",
      "value": "5",
      "choices": [
        {
          "title": "5 minutes",
          "value": "5",
          "isSelected": true
        },
        {
          "title": "15 minutes",
          "value": "15"
        },
        {
          "title": "30 minutes",
          "value": "30"
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Snooze",
      "data": { "x": "snooze" }
    },
    {
      "type": "Action.Submit",
      "title": "I'll be late",
      "data": { "x": "late" }
    }
  ]
}

例子在这里:http://adaptivecards.io/samples/CalendarReminder.html

如何在session.message对象中访问它?

【问题讨论】:

    标签: node.js bots botframework


    【解决方案1】:

    我想通了。在这种情况下,它是x,所以回复它是:

    if (session.message && session.message.value) {
        // A Card's Submit Action obj was received
        session.send(session.message.value.x)
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 2018-11-10
      • 2019-04-20
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 2018-11-09
      • 2020-12-09
      • 1970-01-01
      相关资源
      最近更新 更多