This is a simple bot in Rasa 3.x that provides a workaround for running actions on form initialisation because form validation is now only run after the form is active. See this issue for more details.
This is inspired by this solution here and Rasa's financial demo.
The workaround is acheived by:
-
Add a slot
form_initialized
with a custom type mapping as the first required slot for every form that needs initialization logic. -
Add a custom slot extraction method for
form_initialized
. This will run on every user turn. It will set the slot toFalse
unless the slot is both currently set (it's set by the form below) and the form is still active. This takes care of resetting the slot once a form is closed. -
Create a form validation base class that runs extra logic when
form_initialized
isFalse
, and includes a validation method forform_initialized
that just sets the slot toTrue
. The validation method will only run after the form was initialized. -
Subclass the custom form validation action for any forms requiring initialization logic.