Google assistant notification - chatbot

Refer me to some ready made example of google assistant notification, I'm a tech guy I have already developed app with dialogflow(donot support notification yet), I have both google home and mobile assistant, just want to see google action notification in action.

There's this very detailed guide by Google with ready made code that you can easily adapt to your needs.
It offers code for Dialogflow as well as for the plain ActionsSDK.
Basically the steps are:
Ask for permission
React to it in your fulfillment code (confirming the user's decision)
Notifying Google's backend when it should send a notification to the user (you need a JSON web token). This last step has to be done on some backend which knows about when to send notifications
Those steps are outlined in more detail on the linked site and there's also described how to obtain the token.

Related

App review is required to get Facebook Webhook working. How to develop?

I'm developing an app which must interact with Facebook API Graph and also use webhooks to get live updates. Now I'm facing a problem I can't receive a live webhook updates until my app is reviewed and is not in development mode.
I've found a thread on a Fecebook for developers site describing the same problem and it got official answer - it is not possible. Use Test button in app dashboard to test your webhook implementation they said.
The problem is the Test button sends only one predefined data packet for each of possible subscription with predefined set of fields with fake values, but documentation defines much more fields and little to none information about which fields are sent in different situations (i.e. post added, comment deleted, comment edited).
I'm wondering how other devs solving this? May be there are some community driven reference for a different webhook interaction cases or else.
For now I can't find any information on detailed webhook format except official documentation on available fields (but not supported payload shapes).
Our current workflow looks this way:
create test app
implement webhook handler using only documentation
prepare test payload and check it is working
create a screencast of the app functionality using test payloads
go through the review process
when app is approved
make it live and check your implementation against real webhook payloads
You need to create a test app for your existing Facebook app
Once you do this, just accept the permissions for your app and set the webhooks on your own Facebook account.
Since you are an admin of the test app, you will be able to set webhooks on yourself without having to get your app approved.

Google assistant account linking with facebook

I'm trying to make a chatbot with Dialogflow for Google Home. It requires the user to input a URL. Now it will definitely be a long and complicated URL which I can't recreate and I can't have the user speak into the google home.
The idea I had was that the user would input the URL on an agent on messenger. I store this on a Firebase database and then access it with a second agent.
Now the issue I have is authentication, I was hoping to use account linking on my google action with facebook. But I can't login to Facebook with google home. Or if I can, I can't find any documentation specific to that case. Facebook doesn't provide the necessary client ID and secret(as far as I can see).
I managed amazon and Gmail account linking with Alexa and an Amazon Echo. In those cases, you would have to login to google or amazon on the Alexa app or webpage. Then this will be integrated with your Echo and the skill will become usable.
Anyone have an idea of how I can make the link happen, if not then anyone have an idea as to how I can solve the overall problem?
This question has been left unanswered on other forums, but I was hoping to either get it solved or find an alternative.
There are three approaches to solving your overall problem - getting the URL manually entered and available to your Action. Two of them tackle it the way you've suggested - involving authenticating to Facebook and tying that to the Assistant account somehow. One solves it entirely inside the Assistant.
Account linking to the Facebook account
You've tagged firebase-authentication, so I'm going to assume that you're using it to do the auth and you've enabled Facebook login through it. This means your user has a "Firebase Account", but they log into that account using Facebook.
I will assume you have a way to get the URL from messenger once they're logged in.
The trick in this case is to setup Account Linking between their Firebase account and their Assistant account. This is done by setting up an OAuth2 server that has access to the Firebase accounts and will create authorization and refresh tokens that are given to the Assistant.
In the Action, you'll send the user to the Sign In helper, which will redirect them to your login page and send back a one-time auth code to the Assistant. The assistant will then use your OAuth2 server to exchange this code for auth and refresh tokens. Periodically it will use the refresh token to get new auth tokens.
When the user returns to the conversation through the Assistant, you'll be handed an auth token and you can use this to lookup the user. Since you also know their Facebook account, you can get the URL via however you planned to do so.
There are drawbacks to this method - it is very complicated, and setting up your own OAuth2 server is not for the faint of heart. You may be able to use something like Auth0 instead of Firebase Authentication to accomplish the same thing, but then you don't have the ease of access to the Firebase database.
Account linking to both Facebook and Google
In your Firebase account, however, you don't need to limit them to just logging into Facebook. You can have them use Firebase to record both the Facebook and Google accounts that they're using. This would "link" the two accounts together in your system.
With this, you don't need to setup an OAuth2 server. Instead, you can have the Assistant use Google Sign In for authentication. If the Google Cloud Project that Firebase is using and the Assistant are using are the same project, then once the user has logged in to your project's web page with their Google account, you'll get an identity token on the Assistant which will contain their Google ID. You can use this to match up with their Firebase account and get the Facebook ID and proceed from there.
But this is still a lot of work and kinda messy, jumping between systems.
Using just the Google Assistant (and maybe a web page)
If you're willing to make some assumptions about the devices your users are using, then you may be able to do it all just using the Assistant. The Assistant doesn't just run on the Google Home and other smart speakers, it also works on most current Android and iOS devices.
So you can detect if they have such a device available and, if they do and they're not currently on it, direct them to switch to that device when you need the URL.
If they don't have such a device available (perhaps because their version of Android is older), and you think this may be a common scenario, you may need to make another entry source available. This could be one of the solutions above, or you may want to just have a simple web page (done via Firebase Hosting and Firebase Functions, perhaps) where they log in using their Google account (so you get their ID) and you let them enter the URL. If you just need a URL - going through Dialogflow may be more complexity than you need.

How to develop an app that integrates Google Home with Login using Node.js, Firebase and Swift

I have been making Google Home apps, but now I want to make apps that are connected to Firebase server and DialogFlow API. How is it possible to integrate user authentication in an ios app to identify that user who is using Google Home with that login state?
For example, if I make a restaurant ordering app, I want any user to make a request through Google Home and the user can check his/her ordering history on an ios app.
A user logs in through an app and then how does google home detect that user as a logged in user? I have been searching how to implement this, but nothing hits.
You will need to implement account linking for Actions on Google. This will require two server-side components that you'll need to build:
You'll need to create an OAuth server that will allow the user to authenticate to your service (and use Firebase auth as a component of this) and authorize the Google Assistant to access your service. It does this by generating tokens that it hands to the Assistant.
Your Dialogflow fulfillment webhook will get this token passed to it as part of the conversation. It uses this token to determine which user is making the request and confirm it is valid.
There are OAuth services that are available that work with Google's auth that you should be able to fit in here, or you can write your own using Firebase Hosting and Firebase Cloud Functions. The Dialogflow webhook can, of course, be done using Firebase Cloud Functions.

DialogFlow: Google Calendar Event function from Google Actions (Oauth2)?

I have created an agent in DialogFlow that interacts with the user giving her the ability to check for details like demographic from a back-end database. I have achieved this using Fulfillment/Webhook calls and have successfully parsed/returned different types of Responses to the user to play with. I have tested this on both an Android device and the Google Actions Simulator.
Now, what I want to achieve is to give user the ability to "Set a Reminder" on a platform like Google Calendar or similar through my App. By default, Google Assistant does this by simply telling it to "remind me..." and Google creates a reminder in the calendar. But as soon as I invoke my app, the Assistant is out of scope so using the "remind me" command won't work. I want to use the Google Calendar for example to create a reminder through my agent so that the user is notified at the due time.
I understand that when the user invokes an App in Google Assistant, she is using her Google credentials so I guess if I want to use the App to create a reminder, I should have the option. I have had a look at the Calendar API but I am not sure if I should proceed that way. Is there a better way of achieving this?
Please note, I want to use a reminder service that is available to the user without subscribing to a third-party service.
The Calendar API is the way to go. Details here.
In those docs you'll see reference to the access token, which you can get by using the helper intent askForSignIn (example of use here in one of Google's example projects).
Hope this helps!
So for all those who are facing the same issue, here is what I did:
First created an account on https://auth0.com
Followed this guide to configure the necessary settings to link to Google Assistant (ignored the Jovo part)
Used Auth0 guide to configure and link to my Google project credentials (ignored the Admins SDK Service part)
Now when I run my Google Actions App on the device, a button "Link [App Name] to Google" showed up. Clicking on that "signed me in".
Parsed the response in my webhook to grab originalRequest.data.user.accessToken
This is the token mentioned in #lukedavis answer. The next step was to use the token to execute a call to the Calendar API. Upon trying that, I am facing a different problem which I am trying to find the solution for. But the above should assist those who wish get the accessToken.

Developer Access to Google Assistant Conversation History

I am developing a Google Assistant app for Google Home, and about to launch the app. I am wondering, once my app is live on the Google Assistant platform, whether I (as a developer) would have access to all of the conversation histories as users interact with my app.
If so, does Actions on Google / Google have some sort of interface to view / download the history? Or, do I have to log and capture the history myself? I thought the history will be really helpful for me to improve my app.
Many thanks!
It depends a bit on how you have built your Action.
If you have built it with one of the templates - then no, you don't have access to the conversations.
If you have built it with the Actions SDK or with Dialogflow, then you will have access to quite a bit of information that is delivered to your fulfillment webhook. If you have intents that do not send anything to your webhook - you will not get that information.
There are tools that help you examine conversation flow, see where users get stuck or fall out of the conversation, or how they're using your Action. Most of them have good integration with the Actions on Google libraries. I use a combination of Chatbase, Dashbot.io, and Google Analytics.