Calling an action recursively within

Greetings. I’m looking for a way to recursively call an action within if a certain condtition is true without consulting the stories file. Once the condition is false, then the story may resume. I would also like to know if there is a way to call an action from another action ( something like dispatcher.utter_template(template) but this time it would be dispatcher.restart_on_action(action) ).

If no such methods exist (I’ve searched though the code to no avail), then I could build them myself. In this endeavor I would appreciate guidelines on what to watch out for.

Thanks in advance.

Actions are nothing but execution of some functional logic , in your case, I am not sure why you need two actions

in your run method

if condition true:
  return true

I guess this will continue the story to the next action

but utlimately you always need to dispatch a message to the user, the last message should always be from the bot

Thank you for the quick response. Forgive me for not providing more context. I have an action that should recursively prompt the user for input of the same entity (for example vote options, where a users first input could be John, the second Mary, and so on (the number of vote options would be unknown)). Each time, the data is captured and stored in a list, which is then used to set the slot vote_options. Now given that the number of times a user will provide vote options is unknown, seems not the best place to control this flow, as there the number of times a user is prompted must be hard coded or generated during training, leading to stories with multiple calls to the same action. I would hope that an action could be called once and then handle its own recursion, calling itself so long as a certain condition is true. To this end I seek a method of calling an action within an action

@souvikg10 @akelad Do you have any idea ??

if condition true:
return true

it must not go to next action / state until condition is true.

what will happen if the condition is false?

@souvikg10 if the condition is false so it must proceed to next state of story. while if it is true it must stick to same action. it must listen and run the same action. Till the action is not false.

   def run(self, dispatcher, tracker, domain):
       ents= ['mango','apple','banana']
       ent = next(tracker.get_latest_entity_values("names"), None) 
       if ent not in ents:
           #tracker._paused = True #ConversationPaused()
           dispatcher.utter_template("utter_ask_again_fruit_name", tracker) #bcz we do not have that fruit
           #here how can I rerun the same action, without processing to next state, until i do not the matched fruit.
           return []
       #tracker._paused = False #ConversationResumed()
       dispatcher.utter_template("utter_ask_for_home_address_to_deliver", tracker)
       return ()
## Generated Story -2116955147822496342
* Greet
    -  action_ask_fruit
* Fruit {furit : 'apple'}
  - ask_name
* Name
 -  utter_address
* Closing 
  - utter_close

I think you need FormActions to do it cleanly

it is not possible in custom actions ??