Using reminders in Rasa…

Simran Kaur Kahlon
Gray Matrix
Published in
4 min readNov 15, 2020
Image Source — rasa.com

Rasa is an open-source machine learning framework for automated text and voice-based conversations. It is used to build chatbots that can be integrated on the Web, WhatsApp, and any other platform.

Reminders are an integral part of any chatbot. You want the chatbot to be like an assistant and reach out to you, and help you remember things.

The other important use of reminders could be when the chatbot has asked the user for a certain input and the user didn’t provide it after a considerable amount of time, the chatbot can prompt again for the input it is waiting for.

Rasa out of the box provides reminders, and in fact, they have given an example implementation of it as well in the rasa docs.

I would be using the same example here, but will also share the issue that I faced and had spent almost an hour trying to debug.

A few points to consider about Reminders before we implementing them:

  • They don't work in request-response channels like the REST channel or rasa shell. You could build your custom connector like the CallbackInput channel instead of the RestInput channel.
  • All reminders will be canceled whenever you shutdown your Rasa core server.

Let’s begin.

  • We will have an intent called “reminder_call” with the following utterances,
  • Next, up let's have an action named “action_set_reminder” triggered on this intent. I have used the mapping policy to bind the intent with the action.
  • The first argument to the ReminderScheduled event is the reminder's name, i.e. EXTERNAL_reminder. This name will be later used as an intent that get’s triggered as a reminder reaction.
  • Next up, we pass the timestamp when the reminder is scheduled to get triggered.
  • We can also pass the detected entities that could be in the action that gets called when the reminder is scheduled.
  • Then we have an optional parameter called “name”. All your reminders should have unique names, or else only the latest one will be triggered since all of them will be created with the same name. You can either pass a unique name each time or simply not pass the parameter at all. If you don’t pass the parameter, Rasa will automatically set it to a unique value every time a reminder is set by the user.
  • Lastly, there is a kill_on_user_message boolean parameter, which I believe is self-explanatory.
  • Now, we need to create an action that gets triggered when the reminder is scheduled.
  • As we talked earlier, Rasa will invoke the intent “EXTERNAL_reminder”. So let's have this intent mapped to action as,
  • The action is as follows,
  • Now, I am using a CallbackInput channel, since the reminders won't work with REST input.
  • The Callback channel behaves very much like the REST channel, but instead of directly returning the bot messages to the HTTP request that sends the message, it will call a URL you can specify to send bot messages.
  • You can specify your callback URL in the credentials.yml file as,
  • Also, the callback function looks like as below,

That’s it, you are good to go. Remember to avoid the mistake that I did of keeping the reminder name as same and ended up wasting an hour or so, thinking how come only the latest reminder gets triggered and not the previous once.

Please get in touch in case of any queries.

Thanks.

--

--

Simran Kaur Kahlon
Gray Matrix

JS/ Laravel / AWS / Chatbot Developer #AWS Solution Architect Associate #AWS Developer Associate