# Handling utterances & actions in buttons directly

**URL:** <https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189>\
**Category:** Rasa Open Source\
**Created:** [October 22, 2019, 3:22pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189 "2019-10-22T15:22:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gonesbuyo](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/gonesbuyo/32/4956_2.png) [@gonesbuyo](https://forum.rasa.com/u/gonesbuyo)\
**Post date:** [October 22, 2019, 3:22pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/1 "2019-10-22T15:22:40Z")

</div>

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"
```

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 25, 2019, 1:25pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/2 "2019-10-25T13:25:29Z")

</div>

@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:

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

```

and a story:

```auto
* 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](https://rasa.com/docs/rasa/core/policies/#mapping-policy)

---

<div class="post-metadata">

**Author:** ![gonesbuyo](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/gonesbuyo/32/4956_2.png) [@gonesbuyo](https://forum.rasa.com/u/gonesbuyo)\
**Post date:** [October 28, 2019, 9:25am UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/3 "2019-10-28T09:25:10Z")

</div>

Hi @akelad,

I finally solved it as you mentioned and also with the use of [slot filling](https://rasa.com/docs/rasa/core/slots/#slots-set-by-clicking-buttons).

Thanks for the answer!

---

<div class="post-metadata">

**Author:** ![akshayg11](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@akshayg11](https://forum.rasa.com/u/akshayg11)\
**Post date:** [February 13, 2020, 11:43am UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/4 "2020-02-13T11:43:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [February 17, 2020, 10:18am UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/5 "2020-02-17T10:18:11Z")

</div>

Yes, exactly

---

<div class="post-metadata">

**Author:** ![KheireddineAzzez](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kheireddineazzez/32/17869_2.png) [@KheireddineAzzez](https://forum.rasa.com/u/KheireddineAzzez)\
**Post date:** [April 10, 2021, 5:07pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/6 "2021-04-10T17:07:17Z")

</div>

How ?

---

<div class="post-metadata">

**Author:** ![KheireddineAzzez](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kheireddineazzez/32/17869_2.png) [@KheireddineAzzez](https://forum.rasa.com/u/KheireddineAzzez)\
**Post date:** [April 10, 2021, 5:10pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/7 "2021-04-10T17:10:06Z")

</div>

How do I know the name of the selected button

---

<div class="post-metadata">

**Author:** ![KheireddineAzzez](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kheireddineazzez/32/17869_2.png) [@KheireddineAzzez](https://forum.rasa.com/u/KheireddineAzzez)\
**Post date:** [April 10, 2021, 5:37pm UTC](https://forum.rasa.com/t/handling-utterances-actions-in-buttons-directly/20189/8 "2021-04-10T17:37:40Z")

</div>

what if i have a lot of different buttons and want to know the name of the button we clicked? how do i know the button name !!  
Is there a possibility by using Tracker or other some thing else !!
