Is it possible for rasa to periodically run a python script on its own?

I am fairly new to rasa. I am trying to create a weather bot and I was wondering if its possible for rasa to automatically send me a weather update every 1 hour without needing for me to request a weather update. Like running a python script every hour on its own and then using the dispatcher.utter_message command to send an update. Any help is appreciated

I think you should use this library. https://github.com/agronholm/apscheduler. You will need:

  • 2 functions in RASA action server: let’s call them Activator action and WeatherReport action
    • Activator action will be used to activate the scheduler
    • Every time the scheduler run, it will call WeatherReport action.
  • An intent wired to the Activator function.
    • This intent is used to recognize that you want to receive weather report.

After you have done all the above you can send the message to RASA to receive weather report to your own channel (Messenger, Twitter, …)

Hope this helps.

2 Likes

Or another way is modifying this reminderBot. Same principles like my last post but using rasa_sdk events instead: https://github.com/RasaHQ/rasa/blob/main/examples/reminderbot/

Sorry for the late reply I understood about adding 2 functions but what I did not understand is the second part Do you mean the intent in the NLU? How would I wire a intent to a custom function like Activator?

You can define a custom action with this document: Actions

You can see an example about wiring intent with action here: Responses

Just replace the action: utter_greet with your action name.

You can see an example here rasa/examples/reminderbot at main · RasaHQ/rasa · GitHub. Like I said, same principles, just use rasa_sdk Events instead of the library.

1 Like