Wondering if actions can be invoked by webhook - dialogflow-es

I understand that API.AI works when intents being triggered and responses through a client like Google assistant. I am just wondering if it can subscribe to a certain event and gets triggered.
Basically, I am trying to find out how my server can send me a message when a certain event occurs (e.g., When weather changes from rainy to sunny, I want my chatbot let me know even if I did not ask)

Actions on Google does not support notifications or events. Right now, at least, it is request-response only, in the same way a web server works (which is why webhooks work so well for it).

Related

Trigger a custom alert phrase (Intent) with Dialogflow

I'am new to Dialogflow, although it is easy to understand, I couldn't trigger an Intent with a custom event.
The task that I have to implement is that when an alert is detected in the backend node.js webhook (example: boss wants something done) the google assistant must alert the employee.
I tried with:
https://dialogflow.com/docs/events/custom-events
https://developers.google.com/actions/assistant/updates/notifications
But I couldn't get it to work.
Am I on the right track? or are there other solutions?
Push notifications works fine.I was able to send notifications in real time with some tolerable delai.
the following link has more details than the one on Google Actions website https://yoichiro.github.io/codelabs/actions-updates-and-notifications/?index=codelabs%2F#0

How to use trigger event in facebook messenger bot

I'm developing Facebook messenger bot. Based on the official sample
here made by Node.js, Express, ES7.
I want to use Firebase database, trigger event.
If someone updates the database, send notice to certain people. I add source code "Child Changed" to "messages.js" in messenger-api-helpers, but it doesn't work.
I can check working "Child Changed" in HTML, but in messenger, I cannot.
Where should I write the trigger events code?
You should definitely use Facebook Messenger Broadcast API for this kind of functionality. This will broadcast a notice/broadcast to users.
Caveats:
You have to apply for this permission. (pages_messaging and pages_messaging_subscriptions.Takes about 1-2 days, but
can test on Admin/Test users of the app)
Each broadcast has to be a separate broadcast. (e.g. you can't send image and a text together, each has to be its own individual broadcast).
Have some kind of un-subscription option as well. FB user might think you are spamming even if you clearly say in the messages that your bot will send updates.
Use custom labels to create targetted sends. So you can either subdivide who you will send updates to about specific issues or just label people if they unsubscribe to your broadcast or not.
Basic workflow:
Get permission to broadcast.
On event in your Database. Start process.
Create message_creative_id via POST to endpoint
Use message_creative_id to POST a broadcast_messages
On a successful send you will get back broadcast_id

Return response to Google Assistant via API

I have a Actions on Google project that uses api.ai for its actions. This is working well and I can see request/responses appear on the google assistant interface (On mobiles and simulator)
One of my usecases for api.ai needs to broken into 2 parts, in that we have to inform the user that the processing has started and then inform them again once its completed (without them reprompting for the output).
Im trying for a way to inform the user who is using the Google assistant when the processing is completed, but have failed so far. Something like this
User: I would like to see if my loan request is approved
Google Assistant: Hold on, let me check and let u know .
.... (Makes a webservice call to the backend asynchronously)
.... After few seconds ...
.... Postback to google assistant from the webservice
Google Assistant: Thanks for holding, your request is approved.
Im not sure how to do the "postback to google assistant" call. I have tried to get the SessionId from the Api.AI call and then use that to make a event request , but that doesnt seem to send the response to the assistant. Google Assistant seems to be using the formats defined in https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest, but Im unsure how to get the ConversationToken and use that for sending the response back to the user.
Short answer: you can't do that.
Slightly longer answer: At least right now, there is no good way to send a notification. Your Action can only respond to a specific statement from the user. You can say something like "ask again in a minute and I should have a result for you", but that isn't a great experience. At Google I/O 2017, they announced that notifications would be coming to the Google Home at some point... but gave neither a time frame nor any information about an API.
Long, but probably still unsatisfying answer: You can look into Transactions which let them initiate purchase or request of some sort and then "check out". Once they have checked out, you would confirm that a transaction is being processed with an OrderUpdates and then can send updates with the status of the "order". These status updates can turn into notifications or user's can query the state of the order at any time. Transactions don't require payment, so this may work depending on your needs.
However, there are a few things to note. This is still in developer preview, so things may change in the future. It also doesn't work on all surfaces where the Assistant runs, so while it does work on Assistant on phones, it does not work on the Google Home right now.

Google Actions with custom webhook

I have built a small conversational bot using API.AI with Node.js as the back end. So every time a user makes a request it goes to my server and then from my server to API.Ai and it follows the same route with a response.
Now, I want to integrate it with Google Actions. But, Google Actions allows me to use API.AI as my webhook whereas I want Google Actions to talk to my server.
I have checked everywhere and can't find the correct process. Any, help will be appreciated in Integrating Actions with custom webhook instead of API.API
The normal way it would work would be to have the Google servers for the Assistant talk to API.AI, and then API.AI would call your webhook. This lets API.AI do all of the natural language processing (NLP) and not have you attempt to write this part yourself to load into the Actions console.
Your API.AI project and your Action project need to be the same - if not, you can create a new Action project using the same project as API.AI, or you can export the contents of your API.AI project and import it into a new one.
Your API.AI project also needs to have the Actions on Google Integration turned on. From the left menu, select Integrations and then the Actions on Google tile and turn it on.
However
If you want to send things through your server, and then have your server call the API.AI API yourself, you can certainly do this. You would develop against the Actions SDK and provide an actions.json file which describes the intents and webhook to use.

How to set Slack bot presence "online" when using Events API

I have a bot for Slack implemented using RTM (https://api.slack.com/rtm) which works well but requires WebSocket connections for each user active all the time. After rewriting it using new Events API (https://api.slack.com/events) the bot works well too but appears "away" all the time. Apparently Slack determines bot's status by checking WebSocket connection which is not good as my goal is to use Events API only. Is it possible to use Events API and make a bot appear "online"?
It's one of the two reasons that we don't move to Events API for our bot. The second is that typing events are not send with Events API.
For what we know (dev4slack community, Slack's direct contacts), Slack works at make able to indicate online presence without the RTM, for bots using Events API. That seems essential, without that, Events API seems to be a half solution.
Now with the RTM gone. Slack announced that the only way to toggle your bot presence is via the app management page.
Official Tweet here.

Resources