chatbotrasa-nlurasarasa-corerasa-x

How can i use action_listen inside a custom action in Rasa


I want to listen to user inside custom action and then continue that custom action. Basically what i am looking for is.

I have a loop in custom action from 0 to 5. for each value i want to take some input from user and continue that loop.

def Action():
   for 0 to 5:
      input = action_listen
      // do something with input

Solution

  • You should use a form for this. A form loops over a set of slots that you define until all are filled.

    Looping with action_listen in a regular action won't work because an action has only one run() method and the events are only added to the tracker once the run() method has returned, after which the action is completed (and you can't get back into it).

    https://rasa.com/docs/rasa/core/forms/