Execute custom actions on server initialization or startup

Is there a way to execute a few custom actions when I start the Rasa server or the action endpoint server?

I have a few custom actions to read data from files and generate various buttons to be used later on.

  1. I need to execute these actions only at the beginning; when I start the rasa server or the action endpoint server.
  2. I need the variables generated from these actions; a dictionary containing some data and lists of buttons to serve various purposes, to be available in the memory for quick access whenever needed in other custom actions.

This is how I have currently implemented this: 1.Configured these actions under the greet intent in my stories 2.Whenever a user greets the bot, these actions are executed



  • greet
    • action_read_files
    • action_generate_buttons
    • action_greet

However, these actions take a few seconds to be executed and I do not need them to be executed every time the user greets the bot, it just delays the bot’s simple response to the user’s greet. I’m looking for a way to execute these actions only when either the Rasa server or the action endpoint server is restarted and persist the variables generated (dictionary and buttons) in memory until the next restart.

I am also looking for a way to execute one of my actions on server startup. @naag Did you make any headway in this?

@tonysinghmss Yes. I am using the Rasa webchat for the UI (GitHub - mrbot-ai/rasa-webchat: A chat widget for Rasa and Botfront), this has an option to send an init payload as a user message i.e., a message sent from the UI to Rasa when the chat window is opened. I used this to trigger an intent at Rasa which would in turn call the init actions.


1.domain.yml - Add an new intent Eg - ‘initialize’

2.stories.md - Add a story with the ‘initialize’ intent and the necessary actions to be executed

3.index.html - Set initPayload as - initPayload: “/initialize” (or whatever your init intent is named)

I guess this should also be possible by using HTTP API (HTTP API) but this would only work when a conversation is in place and you have the corresponding conversation ID. You can write a script to get the conversation ID and post the http request to execute the action you want. I haven’t tried this approach though.

Yes, @naag I figured it out after asking you this thing. I have done exactly as you have explained. I am using BotUI for UI. So I fire the initialize intent from the js as the first thing and then I start the bot.

It achieves the same thing which you have illustrated using Rasa webchat. Thanks anyways for this explanation. Someone somewhere will get benefited from reading our conversation.

Hi , Can you share the code or a link as i am new to python !!

Thank you

Sorry the code I am working on cannot be shared due to company policy. You can go through this link

Call this service from your program to check what conversation has already taken place between your bot and user of the bot, and based on your logic you can either take the old conversation ahead or start a new one.

hey Tony ,