# Set user input as intent after button click

**URL:** <https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433>\
**Category:** Getting Started with Rasa\
**Created:** [December 11, 2018, 12:26pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433 "2018-12-11T12:26:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 12:26pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/1 "2018-12-11T12:26:00Z")

</div>

Hi, Need help to set the user input as an intent, after a special utter.

in my stories I have something like:

```
## story1
 * bonjour
      - utter_bonjour
 * confirmer
      - utter_etape1
 * ideasmine
      - action_SendIntentProblemeSite
      - action_SendIntent_B_S

```

I know that after utter\_etape1 the user will give me his ideasmine but I realy don’t know what this will be like. (can’t extract entity, and don’t have examples to set at first) the intent ideasmine is realy random sentences.

So I want to do something after utter\_etape1 that allows the user to tape his message and click on button “ok” and in this button ok I will set like a payload to the intent ideasmine. the next action after intent ideasmine is to extract the user input and set it as slot to re use it later (you said previously [slot ideasmine] …).

Or is there any way to tell the bot to listen to the next user input after utter\_etape1 and set it directly as ideasmine intent.

Can any one help please?

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [December 11, 2018, 12:54pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/2 "2018-12-11T12:54:54Z")

</div>

hey @chemseddine you can read this doc… [https://rasa.com/docs/core/api/interpreter/#buttons-and-other-structured-input](https://rasa.com/docs/core/api/interpreter/#buttons-and-other-structured-input)

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [December 11, 2018, 12:58pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/3 "2018-12-11T12:58:05Z")

</div>

you can do in this way too…

## story1

- bonjour
  - utter\_bonjour

- confirmer
  - utter\_etape1 buttons:
  - title: “button1” payload: “intent ideasmine random sentence”
  - title: “button2” payload: “other random intent sentencd”

- ideasmine
  - action\_SendIntentProblemeSite
  - action\_SendIntent\_B

---

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 1:06pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/4 "2018-12-11T13:06:27Z")

</div>

Thank you for your answer, actualy i tried that. But this is not what I want, here is an example:

```
 bot: write your ideas now, and then click on the button.
 user: random ideas that comes to my mind (I want to take this sentence and set it as a slot called 
 ideasmine, and i want my bot to recognize it as an intent "ideasmine" to follow the story)
 bot: ok your idea is : random ideas that comes to my mind. 

```

If i do like you said, I’ll use a button with payload: “/ideasmine” but in this case the bot will just understand that this was intent ideasmine but will not asnwer with ok your idea is : random ideas that comes to my mind

```
 class action_SendIntentProblemeSite(Action):
    def name(self):
    return 'action_SendIntentProblemeSite'
def run(self, dispatcher, tracker, domain):
    message = tracker.latest_message
    #print(message)
    return [SlotSet('intent_probleme_site', message)]

class action_SendIntent_B_S(Action):
def name(self):
    return 'action_SendIntent_B_S'
def run(self, dispatcher, tracker, domain):		
    loc = tracker.get_slot('intent_probleme_site')
    response = """ ok your idea is : {}. """.format(loc['text'])				
    dispatcher.utter_message(response)
```

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [December 11, 2018, 1:09pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/5 "2018-12-11T13:09:40Z")

</div>

hey @chemseddine you use unfeaturized slot

[Slot Types](https://rasa.com/docs/core/api/slots_api/#unfeaturized-slot)

---

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 1:12pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/6 "2018-12-11T13:12:23Z")

</div>

I’ve updated my message to show my actions. I actually want the bot to recognize the user input as intent ideasmine in order to follow the story and not ignore it

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [December 11, 2018, 1:15pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/7 "2018-12-11T13:15:13Z")

</div>

so you can define unfeaturized slot in your domain.yml file

---

<div class="post-metadata">

**Author:** ![huberrom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/huberrom/32/1209_2.png) [@huberrom](https://forum.rasa.com/u/huberrom)\
**Post date:** [December 11, 2018, 1:19pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/8 "2018-12-11T13:19:56Z")

</div>

If you don’t have any example for your intent, rasa will not be able to recognize it. The only idea that comes to my mind is to add a pop up in your chat with a text field and then when the user press the “Ok” bouton in the pop up, you send the payload.

Slack has a pop up, it’s called dialogs : [Interacting with users through dialogs | Slack](https://api.slack.com/dialogs)

---

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 1:23pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/9 "2018-12-11T13:23:36Z")

</div>

I’ll try it, not sure if I explained well my problem. My problem is that the bot don’t have any way to predict that :

```
 user: random ideas that comes to my mind

```

is an ideasmine intent, the bot will not know because I don’t know how what this intent will have as input; so I just have an intent called ideasmine but with random things.

Actualy my problem is exactly as @huberrom said. I thought I could use a button and after the user click on it I save the input as slot ideasmine and payload: \ideasmine

---

<div class="post-metadata">

**Author:** ![huberrom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/huberrom/32/1209_2.png) [@huberrom](https://forum.rasa.com/u/huberrom)\
**Post date:** [December 11, 2018, 1:26pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/10 "2018-12-11T13:26:15Z")

</div>

You can use a button, but it’ll be the chat job to add the text as the payload, not rasa

---

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 1:30pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/11 "2018-12-11T13:30:12Z")

</div>

and this is done by what you told me? for slack for example I have to use dialogs?

is it easy to do? I’am new to this.

Any examples?

---

<div class="post-metadata">

**Author:** ![huberrom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/huberrom/32/1209_2.png) [@huberrom](https://forum.rasa.com/u/huberrom)\
**Post date:** [December 11, 2018, 1:38pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/12 "2018-12-11T13:38:33Z")

</div>

Well using slack you’ll have to use a dialog yes, it’s “easy” to implement but not sure how to do it with Rasa.

I didn’t try the rasa integration with Slack, but I pretty sure it’s not handling dialogs yet.

To my opinion you need to :

- Override the slack channel component ([rasa\_core/slack.py at master · RasaHQ/rasa\_core · GitHub](https://github.com/RasaHQ/rasa_core/blob/master/rasa_core/channels/slack.py)) to open a route for dialogs in SlackInput class
- Create the form for your dialog ([Interacting with users through dialogs | Slack](https://api.slack.com/dialogs)) this part is pretty easy
- Create a function to send the payload in SlackBot class ([rasa\_core/slack.py at master · RasaHQ/rasa\_core · GitHub](https://github.com/RasaHQ/rasa_core/blob/master/rasa_core/channels/slack.py))
- Set the route you create in your slack bot in the “Interactive components” ([https://api.slack.com/apps/ACR0LN1DJ/interactive-messages?)](https://api.slack.com/apps/ACR0LN1DJ/interactive-messages?))

I don’t have an example for you sorry, I think it’s going to need a little bit of work to implement it.

Maybe someone has a better solution.

---

<div class="post-metadata">

**Author:** ![chemseddine](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chemseddine](https://forum.rasa.com/u/chemseddine)\
**Post date:** [December 11, 2018, 1:42pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/13 "2018-12-11T13:42:14Z")

</div>

Thank you for the answer. I’ll try to found a way to do it. My stupid solution was to tell the user to begin his message by ideasmine: and then in my intent indeasmine i added ideasmine:

But it’s not good to tell the user to begin his sentence with: …

any way thank you for your answers, thank you also @JiteshGaikwad

---

<div class="post-metadata">

**Author:** ![huberrom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/huberrom/32/1209_2.png) [@huberrom](https://forum.rasa.com/u/huberrom)\
**Post date:** [December 11, 2018, 1:43pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/14 "2018-12-11T13:43:44Z")

</div>

Yeah when I started using chatbot, I had the same idea but it’s not the good way to do it

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [December 11, 2018, 1:50pm UTC](https://forum.rasa.com/t/set-user-input-as-intent-after-button-click/3433/15 "2018-12-11T13:50:32Z")

</div>

Welcome @chemseddine and thanks to you too @huberrom 😉
