Call one custom action from any other custom action



This code snippet is from a function “action_hello”. Depending on the value of emp_des I want to execute “action_hello_hr” or “action_hello_emp”. How do I call those actions?

I tried doing it in these ways:



ActionHelloHR().run(self, dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any]))

Neither of them seem to be working as I want it to.

Also, I just call the “action_hello” in the story.

What do I need to do to execute the actions?

wouldn’t it be an option to define two functions which will do the same thing as those other custom actions and return their events in your custom action?

  # Inside your custom action
  return ActionHelloHR(...params) if condition else ActionHelloEmp(...params)

Hi @Mappi I’m sorry but I’m unable to figure out what you mean. Can you please clearly state the commands that I should use, because I think I tried all the simple ‘function call commands’ but it did not work. (8.6 KB)

Like I stated, I think you should isolate the functionality of those custom actions and execute them in a normal python method. In this case you would just pass the stuff (dispatcher, tracker…) you would need for said function and have them propagate the correct events back to the parent if you have any.

Hi @Mappi, I removed the two conditional actions and replaced them with regular python functions imported from a python file. It works fine for me now.