Bot-initiated notifications (again)

This issue has been brought up a lot here, but I haven’t seen a clear response. I’m new to Rasa, so sorry if the answer is obvious.

My use case requires that the bot proactively sends messages to users based on external events in my application. These are not scheduled events. e.g., if an event occurs that impacts a customer, I would like to notify them with a message and then allow them to continue the dialog in Rasa’s normal request/reply model.

User: Hi.
Bot: Welcome to the asteroid alert system. You will be notified when an asteroid is heading toward earth.
User: Great
Bot: OK, we’ll stay in touch
<An arbitrary amount of time passes when the bot’s asteroid detection system triggers>
Bot: Hey, an asteroid is heading towards the planet. It’s been nice knowing you.
User: :frowning:

So what the best approach to send this message to the user?

1 Like

Hi @mmm3bbb,

Due to the single-turn dialogue system used by Rasa Core, the bot can’t send the user a message while it is performing action_listen.

With that in mind, I think the best approach would be to have this external notification system send a message to the rasa endpoint which triggers a custom action to dispatch a warning and return a UserUtteranceReverted() event. You can accomplish this with the MappingPolicy

1 Like

Thanks Tom. I will dig into API this week, but can you clarify the bit about dispatching a “warning”? Is this the message I want the bot to send to the user?

Also, I’m unclear about the sequence of execution. As I read it, UserUtteranceReverted() will revert all events to the point right before my external service sent the message. But doesn’t that include the BotUttered event as well? (In other words, how do I remove the fake user message but not the real bot response?).

Yes, by warning I meant the bot message, i.e. “Hey, an asteroid is heading towards the planet. It’s been nice knowing you”

You’re correct about UserUtteranceReverted(). Keeping the bot message without the user message is something we don’t support at the moment. You could always keep track of the warning status with a slot in your custom action though.

1 Like

OK, I think I see… the message will be delivered from rasa to client, and UserUtteranceReverted() will just remove the fake client request and action response from history. Given that clients (e.g., Messenger) manage conversation history, does it even matter what’s in server-side conversation history?

I understand the slot idea, but the real use cases are quite varied (e.g., flight tracking for specific routes, identification of slow moving SKUs to run promos on, tracking specific crypto prices, etc., etc.).

OK, I think I have enough to experiment with now. Thanks.

Hi @MetcalfeTom.

I don’t see how to send a message to rasa that causes output of action to go to connected output channel. Here is my configuration:

I have a rasa and action server running. There is a single action (action_hello_world) which just returns “Hello world.”

I start the rasa chatbot (using sockets.io). From this, I get sender_id.

Now I want to call some endpoint that will force Rasa to send “Hello world.” to the chatbot.

I have tried to POST /conversations/{id}/execute

And indeed this executes the action, but returns results to the requester (e.g., Postman) and does not send to current chatbot conversation. I read the description and that is the correct behavior.

So what do I call to have output go to conversation instead of caller?

@MetcalfeTom Just checking in again to see how to have the response go back to the connected channel instead of the REST API requester.

Hi @MetcalfeTom - could you please share some code that achieves this? I’ve been racking my head this entire week to have bot-initiated conversations and it just doesn’t work. I think this is a very important feature that Rasa lacks at the moment !

@adityajohar Which connector are you using? I think posting back to everything except websockets is straightforward. If it’s websockets because of webchat component, can u use this one instead?

Hi @adityajohar Did you get any solution to your problem

Were you able to solve this? I have been experimenting but with no luck, and I’m desperate to setup some sort of notification system

Thanks,

Have you checked out the External Events doc yet?

1 Like