Handle interactive input

When the interactivity input modality is configured for the current channel and node, qa action messages in response payloads can include information defining interactive elements. Interactive elements allow the user to select an entity value from a small set of options via an interactive form element. This information is sent to the client app in the selectable field.

Here is an example for an interaction to collect for a yes/no entity:

{
    "payload": {
        "messages": [],
        "qa_action": {
            "message": {
                "nlg": [],
                "visual": [{
                        "text": "So you want a double espresso , is that it?"
                    }
                ],
                "audio": []
            },
            "selectable": {
                "selectable_items": [
                    {
                        "value": {
                            "id": "answer",
                            "value": "yes"
                        },
                        "description": "Image of green checkmark",
                        "display_text": "Yes",
                        "display_image_uri": "/resources/images/green_checkmark.png"
                    }, 
                    {
                        "value": {
                            "id": "answer",
                            "value": "no"
                        },
                        "description": "Image of Red X",
                        "display_text": "No",
                        "display_image_uri": "/resources/images/red_x.png"
                    }
                ]
            }
        }
    }
}

The text field in the QA action message visual indicates the question text to display to the user to prompt the interaction. The field selectable_items contains an array of different selectable items to display to the user for the QA action, following the question text. Each selectable item relates to a value for a single Mix NLU entity defined in the underlying NLU model.

The client application is responsible for displaying the elements (in this case, the two buttons), for example using an HTML form, in the application chat window. The UI for this could be implemented in different ways in the client application, for example, clickable buttons, radio buttons, or a carousel.

The client application is also responsible for returning the choice made by the user in the selected_item field of the next Execute Request payload. For example:

"payload": {
    "user_input": {
        "selected_item": {
            "id": "answer",
            "value": "no"
        }
    }
}

In both cases the string field id corresponds to the name of the entity as defined in Mix.dialog or Mix.nlu, and the field value corresponds to the canonical value for the entity in the NLU model.