Depending on metric values/slots

Depending on the entered metric values the story should continue diffently. For example, the chatbot asks for the age of the user. If he is older than 18, he should get the answer “You are an adult person.”. If he is younger, he should get the answer “You aren’t an adult person.”

I thought about defining a float slot ‘age’. Now I need the condition inside the stories of yaml-File. like:

...
- intent: give_age
- slot_was_set:
  - age > 18
- action: utter_adult
...

But of course it’s wrong. But how can I do that?

1 Like

Define a custom action and use the dispatcher to utter a message.

@mp9500 Hi, you can customise this as per your use case : How to Validate Form Input in Rasa | Rasa Tutorials - YouTube you just need customise based on age (> 18 or less then 18 validation).

Or you can see this video : Memory and Slots in Rasa | Rasa Tutorial - YouTube

I trust you you can archived your goal. Good Luck!

@nik202 Thanks for your information and motivation :slight_smile:

The problem is, that in the real case there isn’t only a final answer like “you are an adult person”. There are long stories which representate a decision tree. Depending on the given value I go to diffent nodes with other questions.

I think it shouldn’t be a form because depending on the path different values are required, should it?

@mp9500 you can use anything, as per your stories, but forms can fulfil your use case. If you can share some more info I can give you more clear answer and solution. I suggest you the solution based on age only.

@nik202

Here is an example of a decision tree for my case. I have multiple questions with different paths depending on the user’s input. Simply, I just would like to check the entered inputs.

Maybe I could check the value-slot in actions.py and set a bool slot like “more_than_4_seats” to true. Aftwards I could check in the stories with slot_was_set…

Is this possible?

@mp9500 Yes, you can use slots Domain with button interface. Are you have any database from where you will compare the value of first node, second node and so on?

Note: Bool with take only two values true and false; I will suggest use categorical one (if you have only two node then bool can be possible) or even float if your values of budgets in decimal i.e 20,000.12. or 10.12 etc this much depends on your use case. Start working, and you will get the more idea.

Some of the suggested projects for your reference for the idea generation: https://github.com/RasaHQ/rasa/tree/main/examples

Some more example : rasa-form-examples

1 Like