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

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

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.

Related

Microsoft Bot Framework: How to add Bot to chat via messaging extension?

Let's assume a user chats with another user in a 1:1 chat. (Might also be a group chat.) The user adds a bot and continues to chat while the bot now adds value to the conversation.
We are searching for a way to make adding the bot to a chat as seamless as possible through a simple button click. It seems the closest we can get to a button is using a messaging extension action command.
When the user invokes the messaging extension our backend service runs and can respond e.g. with a card. Now instead of a card is it possible to generate a response to add a bot? There are special responses e.g. for authentication. Is there a response telling the Teams client to add a bot?
Any hints are appreciated.
JIT installation of bot is an option here. You will be able to add bot to user conversation. Check following sample application which helps to add bot instantly: https://github.com/SubbaReddi/89.teams-just-in-time-installation

Send notification to one user with firebase cloud function node

I am trying to send a notification to a specific user using FCM, but I haven't found a way. I have a mobile app and a node server running.
I want to be able to send a notification when the shipment status changes. I have already a function for it in my server I just have to send the notification to the user. Is it possible to achieve this using nodejs or is there a way to implement it in flutter?
I found this code
    var FCM = require('fcm-node')
var serverKey = require('path/to/privatekey.json') //put the generated private key path here            
var fcm = new FCM(serverKey)     
var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)        
to: 'registration_token',         
collapse_key: 'your_collapse_key',                
notification: {            
title: 'Title of your push notification',             
body: 'Body of your push notification'         
},                
data: {  //you can send only notification or only data(or include both)            
my_key: 'my value',            
my_another_key: 'my another value'        
}    
}        
fcm.send(message, function(err, response){        
if (err) {            
console.log("Something has gone wrong!")        
} else {            
console.log("Successfully sent with response: ", response)        
this is a npm package taht lets send a notification but it asks for a registration token.
I hope you can help me. Thanks in advance!
Firebase Cloud Messaging has no concept of a user. Instead it can send messages to:
Specific app instances (so your specific app as installed on one specific device), as identified by an FCM/device token.
A group of app instances/tokens, as defined by your application logic.
A specific topic, to which app instances can then subscribe.
It's up to your application logic to decide how to map from your user ID to one of these options. The most common are to:
Store the device token(s) and your user ID in your own database, then look up the device token(s) for a user when needed and fill them in to the API call you already have.
Use a specific topic for each user ID, subscribe the application to that when it starts, and then send a message to that topic when needed. Note that anyone can subscribe to any topic though, so this approach would allow folks to receive message for anyone whose user ID they know.

Need help to build a time based notification of microsoft Bot

I am looking for a solution where I need my bot to send notifications to all the users that have interacted with the bot before. This should happen on time demand, for example I would like to send notification only for alternate Friday at 5pm CDT.
I have trie the sample 16.proactive-messages but the the notification trigger is based on a controller so we have to send explicit request to
http://localhost:3978/api/notify to proactively message users from the bot.
I am using bot builder Nodejs sdk 4.x to build the bot.
I would like notifications to go on demand based on the set time and date.
The fastest way to meet your requirement is following the official sample that you tried. To send a notification to uses, you should send a request to api/notify endpoint.
You can create a scheduled webjobs to send this request to your bot so that your bot will send notifications to your users.
Hope it helps.

How to receive bot's messages in telegram?

I wrote some bot that sends messages to some channel using nodejs. This bot is an admin in that channel and it can see messages from users using /getupdates api. However it can't see own messages. Is there any way to do that?

Communicating with the web server using Google Home

I have a social networking website developed in php which is hosted on the server. Here people can talk to each other through messages.
I want to send and receive the messages, to the other users through google home. It is not like a chat bot. But here, the first user will send message from google home to the website and then the second user will send the message from the website to the first user who will receive it through google home.
Can this be achieved? Do I have to develop some kind of mobile App, so that user has to send the message to the mobile app and then the app sends the data to the server.
or do i have to use the webhook which is available in api.ai?
Any help will be appreciated.
You do not need a mobile app - it sounds like most (but not all) of what you're trying to do would be handled using API.AI's webhook Fulfillment.
However, you're also trying to do asynchronous operations (send a message or a notification to Home without the user prompting for it). This currently isn't possible - you can currently only send a message in response to the user taking some action.
One possible workaround for you is to allow the user to ask "how many messages are waiting for me" or something similar at any point. You can also play multiple messages in reply to a message they might send. However, you have limits (about 5 seconds) on how long you can wait to send a reply to a user instruction.
You can implement a chat bot e.g. via Dialogflow (former api.ai), however you can just react on inputs. You cannot push a message on Google Home (yet). So you could the bot read your mailbox but not implement a chat.

Resources