I am trying to write a custom action for my bot along the lines of the following :- The first time the custom action is called, the action returns the first value in a list, when it’s called the second time, it returns the second value in the list and so on till the 3rd time, after which if called again, the bot responds with an utter_goodbye action . I can structure my stories such that an utter_goodbye message is displayed after the third consecutive custom action call, but how do I keep a count to query my list? Is it possible to store a counter inside a slot ?
Hi @enginoir, I don’t know if you are trying to implement something like this : https://blog.rasa.com/failing-gracefully-with-rasa-core/
Hi @harshitc ! The scenario that I have in my mind goes like this :-
Assume I have a custom action which contains a list of strings, and every time the custom action is triggered, it responds with a string chosen at random. Let’s say that after execution, my bot asks the user if they found the result satisfactory. If the user says yes, then the bot replies with a goodbye message. On the other hand, if the user says no, then the custom action is repeated, and a different string( different from the first) is returned. But if the custom action is called thrice consecutively, the bot responds with another custom message saying tries exhaused. I am fairly new to rasa, and I’m not sure how to go about writing a story for such a use case. Do you have any ideas ?
@enginoir Ok, I think I get you. This may not be the best solution but as of now if I were you, I will do it like:
- Create an entity and a slot with same name, say try.
- Implement the confirmation using a button and also will use it to set try slot.
- In custom action fetch the slot value by using get_slot() function.
- Update the slot value by one in custom action on every call.
- Set a flag to true if the slot value reaches greater than 3.
- My first command will be to check this flag value and if it’s true then I will run goodbye template and if not then i will follow 3,4 & 5.
I will advice you to give some time reading the documentation. I guarantee it will be worth investing the time.
Good luck with your bot.