Rasa: How to add buttons

Hello My friend and I are trying to built a bot, using the Rasa platform, for the first time! :slight_smile: We are trying to add a button, but we got stuck… :confused: We don’t know where we need to add the necessary ‘things’, to make the button work… We started by creating a button in the Domain file under the right template… But in the payload part, we got a little bit confused… Can someone help us understand how to continue? if this isn’t clear enough we can give more info! :slight_smile:

Hey,

So buttons are used to give suggestions or possibly give the next set of actions which the user might ask while in conversation.

Here is an example:

templates:
  utter_greet:
  - text: "Hey! How can I help you?"
    buttons:
    - title: "What can you do?"
      payload: '/bot_functions'
  - text: "Hello! What can I do for you?"
    buttons:
    - title: "What can you do?"
      payload: '/bot_functions'
  - text: "Hi! What's up?"
    buttons:
    - title: "What can you do?"
      payload: '/bot_functions'
  - text: "Hey! How are you doing today?"

Here the utter_greet is the action taken by the bot under, for example, the greet intent. When the user says “Hey” the bot will respond with “Hey! How can I help you?”. These buttons would be sent along with the responses. So the “What can you do?” will be a text suggestion, but the intent /bot_functions will be sent to your bot when the user selects this option. So the /bot_function is the intent and you’re bypassing the interpreter and directly send the intent to the bot.

Here is a link to the docs: buttons

2 Likes

It is necessary or optional to use quotes '' "" while writing text, title, payload ???:thinking:

2 Likes

Quotes are not required, just normal text. I’ve never tried adding quotes though. Are you asking about the content of text, title, payload or the ‘text’, ‘title’, ‘payload’?

1 Like

Yes, I was asking about content only :nerd_face:

So I just tried it out without the quotes, and it works. Seems like the quotes are optional after-all.

1 Like

is there a way to allow user to select button, or type text?

1 Like

The buttons will be displayed below (or however you configure them if it’s a custom UI). The user can select the buttons or type text.

Oh okay now I understand. Button works just as type a special string. Though in Rasa Shell UI, it only accept to select from button, user cannot type anything.

Telegram => How to inactive or invisible buttons after click one of them. ?

on desktop, is there a method to allow the user to select a button using the keyboard, instead of using the mouse.

Can anyone help me with the same type of issues, if we are asking two different options via buttons and on selection of each there will be different set of utter actions, how can we put this in the story

- text: "Hi! What's up?"
    buttons:
    - title: "Text 1"
      payload: '/<intent 1>'
    - title: "Text 2"
      payload: '/<intent 2>'

You can add multiple buttons as shown above, As per the intent mentioned in the payload and story, bot will pick the response

Can anyone please provide any example story for using buttons?

The Rasa Financial Bot uses some yes/no buttons, starting around line 153 (at least the version that exists at this time)

There are a good many different type of buttons in the rasa-demo repository

1)How do I create multiple buttons. Like for example. I created a button user, got multiple options, and again from those multiple options. How do I do that?

2)Under the same intent I have lots of questions. How do I create corresponding answers to each of those questions .

It will be helpful if you can show along with syntax.

1 Like

Can you explain with an example?