How to consider text input as button click

when presenting buttons to the user (i.e. Yes/No), if the user types in the button text as a message and doesn’t click on the button, the flow is disturbed.

Is there an elegant way to handle it?


When the user clicks on No there are several fallback messages presented. When the user types “No”, the answer is based on NLU and thus not according to the designed button flow.

Thanks :slight_smile:

Both messages are based in NLU, you must have something like this in your code to generate the buttons

buttons = [{"title": "Yes", "payload": "/affirmation"}, {"title": "No", "payload": "/negation"}]
dispatcher.utter_button_message("Did you mean 'Who is my contact person in HR'?", buttons)

when the user clicks a button, it sends the payload to the bot, in this case an affirmation or negation intent. For your problem you need to ad “No” and its variants as examples of the negation intent. Do the same for “Yes” for the affirmation intent.

Thank Gehova!

The remaining question is, how to relate the affirmation/negation to the specific conversation flow. In this case if the user clicked “Yes”, an answer to “Who is my contact person in HR” should come up, but in other conversation flows the user can be asked by the bot “did my answer help you?” and when the user says “Yes” the response is “I’m glad, what else can I do for you”.

So basically the same affirmation action results in two (or more) unrelated responses.

I was wondering if there is a way to make the bot “aware” what the user affirmation is actually connected to. How would you tackle such situation?

Thanks :slight_smile:

Hi @Aviad… Buttons send the payload and not the text that is displayed.

If you want the person to be able to type “no” instead of clicking on the button, you need something like this in your

## intent: deny
  - No
  - no
  - nah
  - Nope
  - Never
  - No way
## intent: confirm
  - Yes
  - yes
  - yep
  - ok
  - right

The button payloads would be “/confirm” or “/deny”. You can send the button configuration in the domain.yml file like this (in the responses or templates section, depending on which version of Rasa you’re using):

  - text: "Did you mean 'Who is my contact person in HR?'"
    - title: Yes
      payload: /confirm
    - title: No
      payload: /deny

In relation to the flow in your stories, you create both sequences in your file. Something like this:

# answer_yes
* ask_question
  - utter_contact_person
* confirm
  - action_get_contact

# answer_no
* ask_question
  - utter_contact_person
* deny
  - utter_did_this_help

If you use additional questions, you have to create different versions of the stories according to the flow you want to interpret.

Thanks for the reply.

The issue here is a bit different as this button card is presented as part of the two-step fallback action. in this case the payload for the “yes” button is dynamically changing based on the detected intent.

So when the user clicks on Yes the payload is the intent name that was detected. If the user types Yes, the bot detects the confirmation intent.