# How to consider text input as button click

**URL:** <https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522>\
**Category:** Rasa Open Source\
**Created:** [February 7, 2020, 2:48pm UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522 "2020-02-07T14:48:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aviad](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aviad](https://forum.rasa.com/u/Aviad)\
**Post date:** [February 7, 2020, 2:48pm UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522/1 "2020-02-07T14:48:11Z")

</div>

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?

example:

 ![Capture](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/3/3b20f553d46d0c215e1f4ade048b24f12e1237e5.jpeg)

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 🙂

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [February 7, 2020, 3:23pm UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522/2 "2020-02-07T15:23:49Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Aviad](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aviad](https://forum.rasa.com/u/Aviad)\
**Post date:** [February 10, 2020, 7:00am UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522/3 "2020-02-10T07:00:44Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![samscudder](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/samscudder/32/4466_2.png) [@samscudder](https://forum.rasa.com/u/samscudder)\
**Post date:** [February 10, 2020, 1:29pm UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522/4 "2020-02-10T13:29:20Z")

</div>

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 `nlu.md`:

```auto
## 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):

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

```

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

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![Aviad](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aviad](https://forum.rasa.com/u/Aviad)\
**Post date:** [February 10, 2020, 3:11pm UTC](https://forum.rasa.com/t/how-to-consider-text-input-as-button-click/24522/5 "2020-02-10T15:11:22Z")

</div>

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.
