Is there a way to use slots as variable in buttons?

Hi, I have a form with multiple questions, and I want to provide options to the user for some of those questions by using buttons. The form is for creating a new task, and one of the questions is for “task owner”. Users should be able to type a name or choose one of the most available 3 team members.

Names in the options are extracted from the database at each time according to the current availabilities. So, the provided names will be different for each time, and we can’t use fixed names in the buttons.

I thought that I can use slots as variables in buttons just like entities in single utterances. I created 3 new slots for “queried names”. I filled these slots with the top 3 three names in queries each time. I passed these slots to the “buttons titles” and “button payloads” as variables as below, but It didn’t work. (I also tried only in “button titles” and only in “button payloads” separately, they didn’t work as well.)

  - buttons:
    - payload: {name_1}
      title: {name_1}
    - payload: {name_2}
      title: {name_2}
    - payload: {name_3}
      title: {name_3}
    text: "Please select one of the names below"

My question is: Is three a way to use slots as variables in the “button titles” and “button payloads”, or a way to use buttons which its text can be changed upon query results?

1 Like

You can utter button messages from your custom actions code. Please see the dispatcher.utter_button_message and dispatcher.utter_button_template methods.

1 Like

Hi @a-anand-91119, Thank you for response, I will try and share the result with you.

Thanks again