Trigger a custom alert phrase (Intent) with Dialogflow - node.js

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

Related

How to encounter reply when user attaches a document/image to a chatbot(Build with dialogflow and kommunicate)?

I have tried many different methods but it is not working properly.Please any one can help me how to send a reply when user uploads any attachments in a chatbot.
To be able to achieve your objective, it is important to understand what dialogflow events are: Events allow you to invoke intents based on something that has happened instead of what a user communicates. Dialogflow supports events from several platforms (like Google Assistant, Slack, and more) based on actions users take on those platforms.
When a user attaches a file or shares location, Kommunicate sends a custom event KOMMUNICATE_MEDIA_EVENT to your bot along with the attached file information. To have an upload intent respond to the KOMMUNICATE_MEDIA_EVENT, follow these steps to create this custom event in your dialogflow bot:
How to add an event to an intent
Go to the Events section of the intent.
Type the name of the event you'd like your intent to respond to (KOMMUNICATE_MEDIA_EVENT).
Press enter.
Click SAVE.
Also remember to add your response that the bot will deliver to a user when they upload a document.
References:
https://cloud.google.com/dialogflow/docs/events-overview
https://docs.kommunicate.io/docs/bot-custom-integration#send-attachments-to-bot
https://cloud.google.com/dialogflow/docs/quick/build-agent
I hope this helps?

Is there any way to use a received sms as a trigger in a logic app if it's not the initial trigger?

I'm trying to use a twilio sms as a trigger for a step in my logic app that isn't at the very start. The app is meant to simulate a conversation between the user and the app so i need the app to wait for the user to respond.
For example, a conversation might go like
User: Hi
App: Please give me an animal
User: Cat
App: Ok, you said cat
All the tutorials I've found on making a sms a trigger for a logic app just show how to use the "when an https request is received" as the very first step of the logic app. I tried adding another "when an https request is received" as an activity after the "send sms" activity where "please give me an animal" is sent but it says "you cannot use this trigger as an action."
Essentially I'm looking for an activity to make the app wait for the user to respond to "please give me an animal" before the app goes into the "ok you said..." part.
This is my first time using logic apps so I'm hoping that makes sense, please let me know if more info is needed.
Sorry you can't. There can be only one trigger. Some actions like something similar to approval flow which could be used but there isn't one for twilio.
Also what you want is really just a chatbot. I think you should look at Azure Bot Service instead. It allows for conversations thought twilio SMS as one of the channels.
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-twilio?view=azure-bot-service-4.0
You can achieve what you are trying to do with Twilio. Twilio Studio send and wait for reply widget will wait for a reply before moving to the next widget. The example below is outbound but can easily trigger off an incoming message, by attaching the Studio Flow to that Twilio number.
Conduct a Survey with Twilio Studio
Also, Twilio Autopilot could achieve a more flexible response model.
Getting Started with Twilio Autopilot

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.

Wondering if actions can be invoked by webhook

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

Resources