简体   繁体   English

如何从自适应卡中的 choiceSet 中获取数据

[英]How can I take the data from choiceSet in adaptive cards

I want the data (ie value inside choices array) inside the red choiseSet when selected and clicked on the btn, I kept an image and added action submit as action.submit as that's my usecase, I am pretty much confused how I can do that, Here's the card payload我希望在选择Red Choiseset内部的数据(IE Inside Choice ranay)并单击BTN时,我保留了图像并添加的操作作为操作。Submit,因为那是我的用户程序酶,我非常困惑我如何可以做到这一点, 这是卡的有效载荷

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
    {
        "type": "Input.ChoiceSet",
        "id": "myColor2",
        "style": "expanded",
        "value": "1",
        "choices": [
            {
                "title": "Red",
                "value": "1"
            }
        ]
    },
    {
        "type": "Image",
        "altText": "it's a image",
        "url": "https://media.istockphoto.com/vectors/bhutanese-ngultrum-btn-vector-id1304476894",
        "width": "100px",
        "height": "100px",
        "horizontalAlignment": "Left",
        "selectAction": {
            "type": "Action.Submit",
            "id": "btn",
            "title": "btn"
        }
    }
]

} }

Once submitted by clicking on the icon, the bot should receive an activity of type message but with no text.通过单击图标提交后,机器人应该会收到message类型的活动,但没有文本。 The data you want is in the value property.您想要的数据在value属性中。

{
  "activity": {
    "channelData": {
      "postBack": true,
      "clientActivityID": "<REMOVED>",
      "clientTimestamp": "2022-04-05T18:43:17.348Z"
    },
    "type": "message",
    "value": {
      "myColor2": "1"
    },
    "channelId": "emulator",
    "from": {
      "id": "<REMOVED>",
      "name": "",
      "role": "user"
    },
    "locale": "en-us",
    "localTimestamp": "2022-04-05T11:43:17-07:00",
    "localTimezone": "America/Los_Angeles",
    "timestamp": "2022-04-05T18:43:17.408Z",
    "id": "<REMOVED>",
    "recipient": {
      "id": "<REMOVED>",
      "name": "Bot",
      "role": "bot"
    },
    "conversation": {
      "id": "<REMOVED>"
    },
    "serviceUrl": "http://localhost:3212"
  },
  "id": "<REMOVED>",
  "timestamp": 1649184197408
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM