I manage a fair bit of user state in actions - mostly flags and counters - so I can be smarter handling failure cases - e.g., if they don’t understand me one way, I’ll try to express it a different way. If they don’t get that, I might do a final way and if that fails, I’ll just set some default value.
So I have a user_obj slot that is a stringified json object that holds this stuff. Ideally, I’d like to just have a few functions exposed to actions that hide all the slot interface. e.g.,
if user_increment('shoe_size_fails') == 10: dispatcher.utter_message("Seriously, I'm sick of asking you. What is your shoe size?")
where user_increment is a convenience function that adds 1 to the user property ‘shoe_size_fails’.
and then user_increment() manages the interface with the slot. Otherwise, I have to return the json string from these functions and then every action validate function has to remember to set the slot, etc. It just makes things much messier.
Is there a way that I can encapsulate the slot set in the user object functions? If not, I’ll probably just maintain it myself outside of Rasa, but I’d like to avoid if possible.