"if" and "else" in stories depending on the custom action

I want to continue storys with some dependings, for example for bot which will be find free rooms in some hotel:

# first
* find_free_room
    - action_find_free_rooms  # this custom action where we send request for free rooms and get them
    - action_show_rooms  # if we have free rooms, then show them to user

# second
* find_free_room
    - action_find_free_rooms
    - utter_sorry_no_free_rooms   # if we havent free rooms, then say "sorry, no free rooms"

Maybe someone know how to do this?

You can set a slot in the custom action, depending on the action’s result. The action has to return a SlotSet event and within the story you can initiate different actions by setting a corresponding line: “- slot{“slot”: value}”. However be aware that slot values are evaluated depending on their type. For text slots, it is only considered whether there is a value set or not, while boolean and categorical slots can be used to affect the dialogue depending on their values. For your use case you might want to use a boolean slot that returns true or false, indicating the result of the custom action.

1 Like

In addition to what @alex38 said, you can also use FollowUpAction as a result of your existing action. That will allow execution in deterministic way.

1 Like

Oh, thanks! its work!

# I advice for everyone to read rasa.core.events, where you can find many interesting)