Communicating with the web server using Google Home - webhooks

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.

Related

Send a Google Chat message from a regular account (not a bot)?

I'm trying to send a notification out using Google Chats. But I have a few problems with the documentation I've been able to find:
It requires me to have a paid service account, which I do not have, and will not be getting
It requires using a chat bot, which (in my understanding) needs to be added to a room, and cannot just send out messages
Chat bots can't send out messages directly to personal accounts?
I'm already using Google OAuth2 authentication to access another Google API, so I'd like to use a Google API to send messages directly from the authenticated account. How would I do that?
So far:
All the documentation I can find is about making a chat bot.
I've considered some alternatives to sending out messages, but due to corporate device restrictions that will not be changing, google chats is my best option.
At the moment what you're trying to do is not possible, for multiple reasons.
You may know this already, but Google Chat is an upgrade to their old "Classic Hangouts" chat. In Google's own words, this is focused on enterprise (i.e. paid) accounts. While personal accounts are also able to upgrade and get some of the benefits, their documentation shows that Google Chat for personal accounts is very similar to the old Hangouts and most of the new features are meant for the paid accounts. This also includes the use of bots.
As you've observed, the Chat API currently only has methods to create and manage bots. There are no methods to send messages as your own account. This could be to prevent spam or because their Chat API is relatively new, since the Classic Hangouts did not have an API, and Chat hasn't fully replaced it yet. Even then, given that Chat is "enterprise-focused", it is uncertain whether or not personal accounts would get access to any new API features.
You could try to post feedback on their issue tracker or request the feature to see if you get a response, but for an immediate solution you may want to just use the Gmail API to send a regular email or reconsider the other alternatives that you had in mind.

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.

Push Notification with GetStream Notification feed

We are currently using getStream in our react web application for notification feed. It is working fine.
We are now planning to use it in our react native mobile app as well. We would like to show a notification (in the top tray or drawer) whenever there is a notification received by a user, similar to how we get in whatsapp or telegram
Does anyone know how this can be achieved. Couldn't find anything about this in their docs. I can see that they provide this functionality with Stream Chat
PS: We are able to get the notifications in the app but we would like to show the notification in the top tray as well so that the user knows he/she has received notifications without opening the app.
Regards,
Varun
I believe your question is about offering Push Notifications for your application. Stream Feeds does not currently implement Push Notifications out of the box so you will have to implement them in your application yourself. One common approach is to use notification webhooks where you have the webhook trigger a push notification for the user from your application's back end infrastructure.
I hope that is helpful.
Best,
Grant

Is there a way to push notification via a chatbot deployed in facebook developed with dialogflow w/ node.js for fulfillment

I'm developing a facebook/workplace chatbot using dialogflow with node.js for fulfillment. Can't seem to find resources for pushing notifications.
I want to be able to trigger sending the message by visiting the webhook url.
You need to use the Facebook Graph APIs to send a facebook notification to a specific user. User can click on the notification to launch the facebook messenger chatbot.
Here is a quick example.
https://graph.facebook.com/v3.0/{user_id}/notifications?template={your_message}&href={link}&access_token={page_access_token}
You can read more about it here: https://developers.facebook.com/docs/graph-api/reference/user/notifications/
Basically, you need to run a web service which when called makes the calls to the facebook notification APIs.
All you need to do is pass the user id, the message/link to be displayed in the notification and the page access token.
When someone first sends you a message via Facebook, Facebook provides you the page-specific user id which you can store in the database.
Page access token can be accessed by going to https://developers.facebook.com/apps

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

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.

Resources