Slots Set By Clicking Buttons

Hi , i’m a little confused in terms of what the payloads of buttons should look like , like this Domains or like this Slots , i’m wondering if it’s possible to set a slot using buttons without the /intent{entities} format in the payloads ? so i want the payloads to be normal texts and clicking them results in setting the slot . What am i missing ?

Thanks.

Buttons are just smaller, more concise bits of information that you can send to your RASA server from your UI. They’re made of 2 parts: the text is what the user should see in the actual text of the button itself. The payload is what exactly is sent to RASA when you click on the button. For most UIs, there’s no real internal distinction between text sent via clicking on a button or by typing it in.

So why do we use payloads? Because they allow you to fire intents directly. For example, if your bot is asking a question with Yes/No buttons, their payloads could be directly defined as their respective intents (such as intent_agree and intent_deny).

RASA matches direct intent commands (as opposed to user input text that should get processed INTO an intent) when they are prefaced with a forward slash (/). That’s why you see payloads looking like

payload: /intent_agree

Hope this helps.

1 Like

and additionally the way to set slots with a button is through the /intent{entity} format. Is there any reason why you wouldn’t want to use that?

1 Like

Thank you @ActuallyAcey for the quick response , i really appreciate it . I got what you meant in your reply , but isn’t it unpleasant for the client’s side to click a button and see the payload /intent{entities} showing up in his chat ? edit : Hi @akelad , i know , this is on me , i’m failing to comprehend how things work out fine . I just want to know that if it’s possible to set a slot using the format /intent{entity} but at the same time not returning the payload in the chat but the text/title of the button , do you see what i mean ?

that’s what the text part of the button definition is for

Oh , Okay , and how is it written in the domain.yml ? let’s take for instance this :

utter_ask_potential:

  • text: “Quel est le potentiel de réalisation de ton idée innovante ?”

    buttons:

    • title: “Fort”

      payload: /choose_potential{“potential”: “Fort”}

    • title: “Moyen”

      payload: /choose_potential{“potential”: “Moyen”}

    • title: “Faible”

      payload: /choose_potential{“potential”: “Faible”}

Where do i add the text attribute ? and wouldn’t this implicate a warning : The provided yaml file is invalid ?

sorry my bad, it is indeed “title” and not “text”. As described here. The way you’ve written it should show the buttons correctly

But this implies that the user clicking on one of the buttons to return /choose_potential{“potential”: “Fort/Moyen/Faible”} in his chat , how do we avoid this ?(correct me if i’m wrong) I want to avoid this :

image

I want the title to appear not the payload after the click…

this is just the way it looks like in Rasa X, how this will look to your end users depends entirely on the platform you run it on later. For example on Facebook Messenger, the button text will show up as the user message, rather than the payload

Oh I see now , thank you for clarifying things out for me , i appreciate your hard work both of you , really !.

Hi again , long time no see @akelad , i’ve actually been working on an application in Flutter and it’s been so fun so far . So what i’m doing right now is running rasa server and rasa actions server locally in LAN , and the flutter app talks to rasa via the rest channel using this :

image

The exchange between rasa and the user is working as intended but i stumbled upon an issue when the json response being containing the buttons attribute (e.g “buttons” : [{“payload”: … , “title”:…},{},{} and so on]) , i created buttons widgets in case the response contains buttons like this :

image

And now i’m wondering on how to proceed when it comes to what to post to rasa server when the buttons are clicked , i had the idea to create a future like this :

image

But right now i have no clue on how to retrieve the sender_id of a user in a perimeter that is outside of rasa , honestly i have no idea how the sender_id is handled in rasa , is it generated randomly ? what i do know is that we can retrieve it via the tracker in rasa but how do i use it outside of rasa ?

Thanks in advance .

Hi @pandaxar not sure if you’ve already figured this out, but the sender_id in this situation is actually the sender you set in your request to the /webhooks/rest/webhook call. So in the case of the rest channel, setting the sender ID is up to you.

1 Like

I actually didn’t figure it out, now i feel dumb .Is it the case for other channels ?

it really depends on other channels, Facebook Messenger for example will have the users sender ID from their Facebook profile automatically

1 Like

Thanks a bunch ! You are a hero to rasa starters !

Why codes as below (exactly the same situation like mentioned before in this post) have the Errors. It doesn’t make sense to me.

  utter_ask_feedback_button:
  - buttons:
    - payload: /feedback_button{"feedback_value":"positive"}
      title: 👍
    - payload: /feedback_button{"feedback_value":"negative"}
      title: 👎
    text: Do you like it?

However, in Rasa 2, I got the warnings:

2020-11-12 21:44:02 ERROR    rasa.core.nlg.interpolator  - Failed to fill utterance template '/feedback_button{"feedback_value":"positive"}'. Tried to replace '"feedback_value":"positive"' but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template.
Traceback (most recent call last):
  File "/home/sz/py36-bert110-grakn181-rasa203/lib/python3.7/site-packages/rasa/core/nlg/interpolator.py", line 28, in interpolate_text
    text = text.format(values)
KeyError: '"feedback_value":"positive"'
2020-11-12 21:44:02 ERROR    rasa.core.nlg.interpolator  - Failed to fill utterance template '/feedback_button{"feedback_value":"negative"}'. Tried to replace '"feedback_value":"negative"' but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template.
Traceback (most recent call last):
  File "/home/sz/py36-bert110-grakn181-rasa203/lib/python3.7/site-packages/rasa/core/nlg/interpolator.py", line 28, in interpolate_text
    text = text.format(values)
KeyError: '"feedback_value":"negative"'

Hi @yiouyou,

What if you try it with double curly brackets like below:

 utter_ask_feedback_button:
  - buttons:
    - payload: /feedback_button{{"feedback_value":"positive"}}
      title: 👍
    - payload: /feedback_button{{"feedback_value":"negative"}}
      title: 👎
    text: Do you like it?
2 Likes

@Johan1us Double “{{}}” works for me. Thanks!

This have me saving amount of time ^^

2 posts were split to a new topic: Setting a slot that captures the value provided by initPayload