All options Buttons Visibility and activeness

Problem Statement:- I wanted to make other options visible and active after one option is selected, the list of option should remain visible and active , so that user can come back to chat and could be able to see and choose those option again if they wants to , i have created options through buttons and payload in domain.yml file in rasa.

Solution Tried But Didn’t Work:- I have tried

  1. "keep_buttons_visible= true " (after payload command for all buttons options)

  2. “disabled: false” (after payload command for all buttons options)

  3. Tried below code by creating file addition with 2nd option

from import ButtonClicked

def button_clicked(event: ButtonClicked): “”“This listener enables the option that was clicked, if it is not already enabled.”“” option =[“option”] if option.get(“disabled”) is True: option[“disabled”] = False

endpoints = { “action_listener”: [ button_clicked, ], }

  1. Tried below code in file with addition to 1st option. class KeepButtonsVisibleAction(Action):

    def name(self) → Text: return “action_keep_buttons_visible”

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) → None: pass

  2. Tried creating class in file and adding that action in domain.yml file and stories,yml file.

a) :- class ResetDisabledPropertyAction(Action):

def name(self) -> Text:
    return "reset_disabled_property"

def run(self, dispatcher: CollectingDispatcher,
         tracker: Tracker,
         domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    for slot_name in tracker.active_loop.slots:
        tracker.set_slot(slot_name, False)

    return []

b) domain.yml:- actions:

  • name: reset_disabled_property python_path: actions.reset_disabled_property

c) stories.yml:- story: Reset disabled property of buttons steps:

  • intent: option1
  • action: reset_disabled_property

but none of the solution helped can anyone please help with the solution?

To make other options visible and active after one option is selected, you can use slot values to keep track of the selected option and enable/disable the buttons accordingly. Here’s a step-by-step solution: Define a slot in your domain.yml file to store the selected option: slots: selected_option: type: text Modify your button payloads to include the selected option as a slot value. For example: utter_options:

  • text: “Please select an option.” buttons:
    • title: “Option 1” payload: “/select_option{"option": "option1"}”
    • title: “Option 2” payload: “/select_option{"option": "option2"}” Create an action in your file to handle the option selection and update the selected_option slot: from typing import Any, Dict, List, Text from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.types import DomainDict

class SelectOptionAction(Action): def name(self) → Text: return “action_select_option”

def run(
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: DomainDict,
) -> List[Dict[Text, Any]]:
    option = tracker.get_slot("selected_option")
    if option is not None:
        dispatcher.utter_message(f"You selected: {option}")
        # Enable/disable other options based on the selected option
        if option == "option1":
                "Other options:",
                    {"title": "Option 2", "payload": "/select_option{\"option\": \"option2\"}"},
                    {"title": "Option 3", "payload": "/select_option{\"option\": \"option3\"}"}
        elif option == "option2":
                "Other options:",
                    {"title": "Option 1", "payload": "/select_option{\"option\": \"option1\"}"},
                    {"title": "Option 3", "payload": "/select_option{\"option\": \"option3\"}"}
        # Update the selected_option slot value
        tracker.update_slot("selected_option", None)
    return []

Add the action to your domain.yml file: actions:

  • action_select_option In your stories, make sure to include the story steps for option selection and handling the selected option. For example: stories:
  • story: User selects an option steps:
    • intent: select_option entities:
      • option: “option1”
    • action: action_select_option With this solution, when the user selects an option, the SelectOptionAction action will be triggered. It will handle the selected option, provide a response, AARPMedicare and enable/disable other options based on the selected option. The selected_option slot is updated to None after handling the selection, allowing the user to choose again if needed.

Handling buttons visibility via custom action isn’t a feasible option, as creating this many actions is very complicated. Any other way to do will be appreciated @stephens if you could help on this, please

I would look at customizing whatever widget you are using to add this functionality.

I’m using rasa webchat widget, so any functionality that can help in keeping all the buttons visible and active even after selecting one option would really be helpful. Thanks in advance.

@stephens any update on this