Need help in creating action_restart action

Hello Friends, I am creating a chatbot using rasa stack framework. I am very much new to rasa stack framework. I want to create and invoke action_restart action when my user breaks out of the story and starts again from the beginning. Can someone help me in this

Just put action_restart on your story :

## story_001
* greet
  - utter_greet
* goodbye
  - utter_aurevoir
  - action_restart

you can override the behavior of this method in your action server :

class ActionRestart(Action):
def name(self):
    return 'action_restart'

def run(self, dispatcher, tracker, domain):
     # Code for your custom restart action

Don’t forget to put - action_restart in your domain.yml :

actions:
- action_restart

Thank you @huberrom for your response. I will add action_restart in my domain.yml file. Do I need to add action_restart to the end of each story of my stories?

Each story where you want to restart the conversation yes

@huberrom. I am sorry if you mis-understood my intention. I want to restart the action when my user breaks out of it the story. It is not my decision.

For example, Let us consider restaurant search. 1. user greets —> bot also greets 2. user asks for restaurant -----> bot asks for type of cuisine 3. if user again greets —> at this point I want to restart the server.

please let me if you don’t understand my question

Oh my bad, then I’m not sure about my answer but I think you can take a look at Slot Filling (the unhappy path section) if you want to use a form.

Otherwise you can add stories when with unhappy path using interactive learning. Not sure if it’s the best solution tho

okay sure @huberrom. I need one more help from you. When I run my bot it will be up and running. when a story is completed, bot doesn’t stop until I enter /stop to get it stopped. Is there anyway that bot could automatically terminate once the story is completed.

please let me know if you don’t understand my question.

Thank you

You can use the stop event in a custom action : https://rasa.com/docs/core/api/events/?_ga=2.253475850.283511516.1544386546-2129902348.1543709757#pause-a-conversation

But it depends what you mean by “stop”. This event will not stop the nlu/core but the bot won’t respond to the user until you resume the conversation.

@huberrom. please look at the screenshot I attached. There my bot is not stopped unless I enter /stop to exit. I want the bot to terminate or stop itself once the story is completed.

I think you understood what I mean right?

I don’t see any screenshot, but I don’t think it’s possible to terminate your bot once the story is completed. It’s usually not the purpose of a bot to stop after it finished answering to one person.

I am sorry @huberrom. I forgot to attach screenshot. Can you please check it

I understood your problem without it don’t worry, but I still think it’s not possible

okay @huberrom. please do let me know if you think something is possible for it. I am actually developing a bot, Can I tag you when I raise any issue asking for your help. so that you can know?

Yes i’ll try my best to answer, but I’m not always available !

Thanks for reply @huberrom. respond to me when you got time.

Hello friends, I am trying to override the run method of custom action_restart to add my own functionalities to the existing one. I followed the steps mentioned in rasa docs for writing custom action restart.

My code looks like this:

class ActionReboot(Action):

  def name(self) -> Text:
      return "action_restart"

  def run(self, dispatcher, tracker, domain):
      print("veda")
      output_json = {"message": "Restarting"}
      .......my functionality......
      dispatcher.utter_message(text=json.dumps(output_json))
      return [Restarted()]

I also put action_restart in domain.yml file.

After all these, when I send /restart message, This custom action is not getting triggered. can someone help me with this please?