I certainly scanned the whole rasa documentation but am completely unable to find specifications regarding buttons in forms. I really would like to use buttons as answer format to fill the slots but I don’t know how to implement it.
If slots are defined like that:
slots:
departure_city:
type: text
mappings:
- type: from_entity
entity: city
role: from
- type: from_entity
entity: city
arrival_city:
type: text
mappings:
- type: from_entity
entity: city
role: to
- type: from_entity
entity: city
arrival_date:
type: any
mappings:
- type: from_entity
entity: date
forms:
your_form:
required_slots:
- departure_city
- arrival_city
- arrival_date
And buttons are defined like that:
responses:
utter_greet:
- text: "Hey! How are you?"
buttons:
- title: "great"
payload: "/mood_great"
- title: "super sad"
payload: "/mood_sad"
How to bring them both together? I would love to have some documentation on that since it is really hard to migrate from 2 to 3 otherwise.
For each slot to fill in a form, Rasa will look for a response called utter_ask_<form_name>_<slot_name>: see Forms
Once the form action gets called for the first time, the form gets activated and will prompt the user for the next required slot value. It does this by looking for a response called utter_ask_<form_name>_<slot_name> or utter_ask_<slot_name> if the former isn’t found. Make sure to define these responses in your domain file for each required slot.
You can then define your response as usual:
utter_ask_welcome_form_wellbeing_slot:
- text: "Hey! How are you?"
buttons:
- title: "great"
payload: "/mood_great"
- title: "super sad"
payload: "/mood_sad"
FInally, in your domain you can define your wellbeing_slot (in above example) as being mapped from an intent (or a trigger intent) (see: Domain):
wellbeing_slot:
type: any # Change the type as needed
mappings:
- type: from_intent
value: some_value_to_put_in_wellbeing_slot_when_mood_great
intent: mood_great
- type: from_intent
value: some_value_to_put_in_wellbeing_slot_when_mood_sad
intent: mood_sad
This should work because the payloads defined in your responses are kinda like shortcuts to the corresponding intents. This also has the advantage that if a user ignores the buttons and types “I’m great”, your form should still capture the intent mood_great.
Thank you! I will try it out. Just a follow-up question: What can “value” be? A string defined with quotations marks or a number? Mainly asking for when I want to use the value for processing…
I’m not sure, the docs don’t precise that, but my guess would be primitive data types like string, number, boolean? Perhaps anything handled in YAML?
You can probably try by writing an action which uses the value and see what you can pass
Thank you a lot! I just tried the solution out you suggested but my bot won’t ask the question with the button solutions. Do you know what I’m doing wrong?
Here is my code:
NLU:
- intent: mood_great
examples: |
- perfect
- great
- amazing
- feeling like a king
- wonderful
- I am feeling very good
- I am great
- I am amazing
- I am going to save the world
- super stoked
- extremely good
- so so perfect
- so good
- so perfect
- intent: mood_unhappy
examples: |
- my day was horrible
- I am sad
- I don't feel very well
- I am disappointed
- super sad
- I'm so sad
- sad
- very sad
- unhappy
- not good
- not very good
- extremly sad
- so saad
- so sad
- intent: inform
examples: |
- [Mambo No.5](song) is my favorite song
- my favorite song is [Saturday night fever](song)
- I love [Take a chance on me](song)
- what do you think about [Let it be](song) as a song
- hmm [dance night long](song)
- I would say [everything from ABBA](song)
- a great song is [coconat banana](song)
- [Let it be](song)
- [walking on sunshine](song)
- Definitely [walking on sunshine](song)
- 5 coffee per day
- 2 cofffe in the moring
- 3 during the day
- 6 in a day
- I drink not much coffe just 1
- only 1 cup
Slots of type any are always ignored during conversations. The propertyinfluence_conversation cannot be set to true for this slot type. If you want to store a custom data structure which should influence the conversation, use a custom slot type.
in Domain
Could it possible that I need to use something like categorical and then write a custom slot mapping?
But I’m wondering why the bot is not even providing the question…
Hi @LindaA,
Missed the post updates, apologies. I’m unsure what is going wrong, but I’d try a few things:
Are the two other slot questions being asked? If so, try putting wellbeing first in your form definition so that you can see if the problem lies with the other slots or wellbeing itself (perhaps it is never triggered at all)
As you wrote, I’d avoid type any and change wellbeing to categorical and num_coffee to float. But I don’t see why that would affect the forms
You could try running rasa shell --debug when chatting with the bot and see what the core model is predicting, that might help too