How to create an azure chat bot which can send chat messages without any user input

711 Views Asked by At

I have tried developing azure bots before. Currently I am trying to find out whether there is any way we could set up a bot that can constantly monitor something and send messages to particular users without user initiating a chat.

For instance, a bot monitors a system and find something wrong and sends a chat message to the user ( Bot initiates the chat in this case ). I did some research but couldn't find any way to achieve this yet.

Thanks in advance,

DM

1

There are 1 best solutions below

3
Eric Dahlvang On

This concept is called Proactive Messaging in the Bot Framework. There are some example in C# here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-proactiveMessages and node.js here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-proactiveMessages

Something to note is that different channels have different restrictions on when a proactive message can be sent to a user. For instance, on Facebook you have a 24 hour window from the time the user messaged the bot. After 24 hours, if the user has not messaged the bot, then proactive messages will not be allowed through.

More information can be found in this doc: https://learn.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-proactive-messages

Edit:

You can also create a Functions Bot in Azure using the Proactive template and it will create a bot that has BasicProactiveEchoDialog.csx that demonstrates how to en-queue a CloudQueueMessage into a CloudStorageAccount. The template will also create an Azure Function that is triggered by additions to the queue. When the function is triggered, it will send the queued message to the user on the channel.