# Bot-initiated notifications (again)

**URL:** <https://forum.rasa.com/t/bot-initiated-notifications-again/12562>\
**Category:** Rasa Open Source\
**Created:** [July 6, 2019, 3:31am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562 "2019-07-06T03:31:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [July 6, 2019, 3:31am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/1 "2019-07-06T03:31:26Z")

</div>

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: ☹

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

---

<div class="post-metadata">

**Author:** ![MetcalfeTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/metcalfetom/32/1422_2.png) [@MetcalfeTom](https://forum.rasa.com/u/MetcalfeTom)\
**Post date:** [July 9, 2019, 1:45pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/2 "2019-07-09T13:45:21Z")

</div>

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()`](https://rasa.com/docs/rasa/api/events/#undo-a-user-message) event. You can accomplish this with the [`MappingPolicy`](https://rasa.com/docs/rasa/core/policies/#mapping-policy)

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [July 9, 2019, 3:24pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/3 "2019-07-09T15:24:16Z")

</div>

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?).

---

<div class="post-metadata">

**Author:** ![MetcalfeTom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/metcalfetom/32/1422_2.png) [@MetcalfeTom](https://forum.rasa.com/u/MetcalfeTom)\
**Post date:** [July 10, 2019, 10:41am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/4 "2019-07-10T10:41:07Z")

</div>

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](https://rasa.com/docs/rasa/core/slots/) in your custom action though.

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [July 10, 2019, 3:40pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/5 "2019-07-10T15:40:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [July 15, 2019, 8:48pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/6 "2019-07-15T20:48:11Z")

</div>

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](http://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?

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [July 18, 2019, 5:27pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/7 "2019-07-18T17:27:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adityajohar](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@adityajohar](https://forum.rasa.com/u/adityajohar)\
**Post date:** [November 8, 2019, 11:46am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/8 "2019-11-08T11:46:07Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [November 8, 2019, 4:10pm UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/9 "2019-11-08T16:10:22Z")

</div>

@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?

> **[assister/packages/rasa at master · keyvan-m-sadeghi/assister](https://github.com/keyvan-m-sadeghi/assister/tree/master/packages/rasa)**
>
> master/packages/rasa

---

<div class="post-metadata">

**Author:** ![AmitK](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@AmitK](https://forum.rasa.com/u/AmitK)\
**Post date:** [December 6, 2019, 9:52am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/10 "2019-12-06T09:52:56Z")

</div>

Hi @adityajohar Did you get any solution to your problem

---

<div class="post-metadata">

**Author:** ![ahson](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@ahson](https://forum.rasa.com/u/ahson)\
**Post date:** [March 12, 2020, 3:27am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/11 "2020-03-12T03:27:09Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![saurabh-m523](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/saurabh-m523/32/7887_2.png) [@saurabh-m523](https://forum.rasa.com/u/saurabh-m523)\
**Post date:** [March 12, 2020, 3:38am UTC](https://forum.rasa.com/t/bot-initiated-notifications-again/12562/12 "2020-03-12T03:38:45Z")

</div>

Have you checked out the [`External Events`](https://rasa.com/docs/rasa/core/reminders-and-external-events/#external-events) doc yet?
