Handling utterances & actions in buttons directly

Hi there,

I want to know how can I directly return an utterance or a custom action (instead of having an intent or a text that is mapped to an intent) when a button is chosen. I need it because I’m developing a chatbot that has several button-based menus which in turn give access to other menus or have to execute actions without them having an associated intent (I need the match to be deterministic in those cases, without dependence on the intent classifier).

E.g. having in domain.md the following (it’s a silly example, but it illustrates what I need):

utter_choose_department:
- text: "Which department do you want to access?"
  buttons:
    - title: "Sales"
      payload: "/utter_sales_access"
    - title: "Marketing"
      payload: "/utter_mkting_access"
    - title: "HR"
      payload: "/utter_hr_access"

...

utter_sales_access:
- text: "Choose an option, please:"
  buttons:
    - title: "Contact sales"
      payload: "You can contact sales department at sales@domain.com"
    - title: "Schedule an appointment"
      payload: "/action_sales_appointment"

@gonesbuyo welcome to the rasa community! Unfortunately you have to have them be associated with an intent. You don’t need to have it rely on intent classification though, if you have:

- text: "Which department do you want to access?"
  buttons:
    - title: "Sales"
      payload: "/intent_sales"

and a story:

* intent_sales
    - utter_sales_access

the action will directly get triggered when clicking the intent. You can also look at the MappingPolicy if you want to avoid writing stories for this: Policies

Hi @akelad,

I finally solved it as you mentioned and also with the use of slot filling.

Thanks for the answer!

Hi @akelad .Relating to this example and the approach that you mentioned in this comment, I will need to create a “intent_sales” intent. Now for my usecase i need this intent to be triggered only by this button. So should i create this intent with no examples because the only way I want that intent to be triggered is through a button?

Yes, exactly

1 Like