cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fernandosilva
Helper V
Helper V

How to get value from radio button and store in a variable

Hi there,

 

I'm using an adaptive card to display a form on the chatbot and there is a choice set in the form as a radio button.

 

I want to know if anyone managed to store the value of the radio button in a variable using Bot Framework Composer, so them I can pass through PVA.

 

See example below:

 

2022-04-05 09.30.26 adaptivecards.io 631c4a22f0e1.png

bfc.png

 

So, I want to store the value "Red" in a variable on Bot Framework Composer, so I can pull it from PVA.

 

Thanks,

 

Fernando

6 REPLIES 6
Monkeyman
Resolver III
Resolver III

Hey

 

you need to go to the parent topic and look at the dialog.result scope. 

in there you can create output variables. 

Check this post’s solution for more info - https://powerusers.microsoft.com/t5/Bot-Extensibility/Pass-variable-from-Bot-Framework-back-to-PVA/m...

 

Please mark this topic as solved if I have helped. 

 

Hey,

 

I got that, but the radio button is inside an action where slide down to show the other fields, like this example:

https://adaptivecards.io/samples/ShowCardWizard.html

with the radio buttons like these ones: https://adaptivecards.io/samples/InputsWithValidation.html

 

So, my issue is to setup the "=turn.activity.value" for the radio button variable and also to assign that variable to the "dialog.result" .

 

I can see the variable when exporting to PVA, but the values are not passing through.

 

Cheers,


Fernando

 

 

Monkeyman
Resolver III
Resolver III

Hey Fernando

 

You can set the turn.activity.value to a user.XXX property and then use the set property to set dialog.result.XXX to user.XXX

Hi Monkeyman,

 

Below is my adaptive card and if you place it on here: https://adaptivecards.io/designer/, you will see how it works, but I believe the values of the variables inside the "actions" must have a different path on turn.activity.value.XXX as simply calling the user.XXX, the value is not passing through. If I take all the actions out and place all the form in a single structure, it goes fine.

 

 

 

 

 

 

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "My details",
            "horizontalAlignment": "Center",
            "wrap": true,
            "style": "heading"
        },
        {
            "type": "Input.Text",
            "label": "Card number",
            "id": "CardNumber",
            "isRequired": true,
            "errorMessage": "Card Number is required"
        },
        {
            "type": "Input.Text",
            "label": "First name",
            "id": "FirstName",
            "isRequired": true,
            "errorMessage": "Full Name is required"
        },
        {
            "type": "Input.Text",
            "label": "Last name",
            "id": "LastName",
            "isRequired": true,
            "errorMessage": "last Name is required"
        },
        {
            "type": "Input.Text",
            "label": "Email address",
            "style": "Email",
            "id": "Email",
            "isRequired": true,
            "errorMessage": "Email is required"
        }
    ],
    "actions": [
        {
            "type": "Action.ShowCard",
            "title": "About Your Phone",
            "card": {
                "type": "AdaptiveCard",
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "body": [
                    {
                        "type": "Container",
                        "id": "aboutyourphone",
                        "items": [
                            {
                                "type": "Input.Text",
                                "label": "Phone Number",
                                "style": "Tel",
                                "id": "PhoneNumber",
                                "isRequired": true,
                                "errorMessage": "Phone number is required"
                            },
                            {
                            "type": "Input.ChoiceSet",
                            "choices": [
                                 {
                                 "title": "Apple",
                                 "value": "Apple"
                                  },
                                 {
                                 "title": "Samsung",
                                "value": "Samsung"
                             }
                             ],
                           "placeholder": "Placeholder text",
                           "label": "Phone maker",
                           "style": "expanded"
                            },
                            {
                                "type": "Input.Text",
                                "label": "What's your phone maker? (E.g. Apple, Samsung, LG)",
                                "id": "PhoneMaker",
                                "isRequired": true,
                                "errorMessage": "Phone maker is required"
                            },
                            {
                                "type": "Input.Text",
                                "label": "What's your phone model? (E.g. S20, Pro   , Mini)",
                                "id": "PhoneModel",
                                "isRequired": true,
                                "errorMessage": "Phone Model is required"
                            },
                            {
                                "type": "Input.Text",
                                "label": "What's your phone memory capacity? (E.g. 128Gb, 256Gb, 1Tb)",
                                "id": "MemoryCapacity",
                                "isRequired": true,
                                "errorMessage": "Memory capacity is required"
                            }
                        ]
                    }
                ],
                "actions": [
                    {
                        "type": "Action.ShowCard",
                        "title": "More Details",
                        "card": {
                            "type": "AdaptiveCard",
                            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                            "body": [
                                {
                                    "type": "Container",
                                    "id": "moredetails",
                                    "items": [
                                        {
                                            "type": "Input.Date",
                                            "label": "Purchase Date",
                                            "id": "PuchaseDate",
                                            "value": "2022-22-22",
                                            "style": "text",
                                            "isRequired": true,
                                            "errorMessage": "Purchase date is required"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "label": "Where did you purchase your device?",
                                            "id": "PurchasePlace",
                                            "isRequired": true,
                                            "errorMessage": "Purchase place is required"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "label": "What's your device IMEI number? (Press *#06# on your phone keyboard to find out)",
                                            "id": "ImeiNumber",
                                            "isRequired": true,
                                            "errorMessage": "IMEI number is required"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "label": "Write your message here (optional)",
                                            "isMultiline": true,
                                            "id": "Comments"
                                        }
                                        
                                        ]
                                }
                            ],
                            "actions": [
                                            {
                                                "type": "Action.Submit",
                                                "title": "Submit",
                                                "data": {
                                                    "id": "123456789011121314"
                                                }
                                            }
                                    ]
                        }
                    }
                ]
            }
        }
    ]
}

 

 

 

 

 

Unfortunately that schema is not working for me when I put it in Designer | Adaptive Cards

It's working now.

 

Copy and paste as a card payload on a blank card.

 

That was because the line below was as a single line and not on the same line than the label.

 

 

(E.g. 128Gb, 256Gb, 1Tb)",

 

 

Helpful resources

Announcements
Register for a free PVA chatbot creation workshop

Register for a free PVA chatbot creation workshop

Learn how to respond rapidly to your customers and employees at scale, using intelligent conversational chatbots.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,854)