Search code examples
adaptive-cards

Adapative Card passing selected value


i need some help here.. I am trying to pass the selected value to my "actions" form, i've googled it, but without no solutions sadly, so i hope theres someone who can help me with this issue. I posted the code below, thanks.

local ChooseId = [==[{
          "$schema": "https://microsoft.github.io/AdaptiveCards/schemas/adaptive-card.json",
                    "type": "AdaptiveCard",
                    "version": "1.0",
                    "body": [
            {

              "type": "TextBlock",
              "text": "Vælg karakter",
              "weight": "Lighter"
            },

            {
              "type": "Input.ChoiceSet",
              "isMultiSelect": false,
              "value": "0",
              "choices": [

                {

                "title": "]==] .. charnames[1][1] .. [==[",
                "id": "1"

                },

                {
                "title": "]==] .. charnames[2][1] .. [==[",
                "id": "2"

                }

              ],

              "style": "expanded"
              
            }
            
          ],

          "actions": [
            {
              "type": "Action.Submit",
              "title": "Sumbit",
              "style": "positive",    
            }
          ]
          
}]==]

Solution

  • to get the select input you have to do a few minior changes to your card.

    The ChoiceSet as such needs to have an ID set, the choices don't need ID but need value properties. Once changed you get something similar to this on submit:

    "data": {
      "choice": "2",
    }
    

    Updated card for reference:

    {
          "$schema": "https://microsoft.github.io/AdaptiveCards/schemas/adaptive-card.json",
                    "type": "AdaptiveCard",
                    "version": "1.0",
                    "body": [
            {
    
              "type": "TextBlock",
              "text": "Vælg karakter",
              "weight": "Lighter"
            },
    
            {
              "type": "Input.ChoiceSet",
              "isMultiSelect": false,
              "value": "0",
              "id": "choice",
              "choices": [
    
                {
    
                "title": "]==] .. charnames[1][1] .. [==[",
                "value": "1"
    
                },
    
                {
                "title": "]==] .. charnames[2][1] .. [==[",
                "value": "2"
    
                }
    
              ],
    
              "style": "expanded"
              
            }
            
          ],
    
          "actions": [
            {
              "type": "Action.Submit",
              "title": "Sumbit",
              "style": "positive"   
            }
          ]
          
     }