Call a form action recursively

I am working a chatbot and need call the same form action again and again until it reaches to a certain number. I can get this work using FollowupAction and the logic is below:

class ActionMyForm(FormAction):

            # here I use a slot to count how many times ActionMyForm is called.
            if number_of_calls > 6:
               return []
               # reset required_slot and then call this:
               return [FollowupAction("action_my_form")]

However, when it reaches 6 times, the bot is stuck at action_my_form although all the required slots are already filled.

Any idea how to achieve this?

hi @liferoad ! I’m very curious, what conversation requires this behaviour?

The way I would recommend doing it instead is to set a slot with the number_of_calls value, adn get rid of the FollowupAction (I wouldn’t recommend using those and I’d like to see them removed someday). So long as the form is active, the FormPolicy will keep predicting the formaction so this should work as desired. You can bake any additional logic into the required_slots method, see Forms

@amn41, thanks for your suggestion. Essentially, my bot need fill in a list using user’s inputs. The number of elements in this list is dynamically changed based on user’s inputs. What I do now is required slots return [‘my_element’]. I use number_of_calls as the index and the slot ‘my_element’ stores the current value and is added into the list. Before FollowupAction is called, I reset required_slot from null to my_element. So the form is active.

I indeed checked that link many times but I have no way to know the required slots element. I could add some slots like my_element_0, my_element_1, … but the number of my_element is then fixed to a number.

that makes sense, but if the form is active you shouldn’t need the followupaction