Push notifications for Google Assistant (Actions on Google)

Push notifications for Google Assistant (Actions on Google)Sascha WolterBlockedUnblockFollowFollowingMay 19The Google Assistant push notification feature allows you to send notifications, which if tapped, trigger a predefined intent of your Action.

To be able to send notifications to a user they must first explicitly opt-in to receive notifications for a specific intent.

This intent must be configured to be eligible as intent that supports push notifications.

Setting up Notifications the first time might be a little tedious, but once you succeed, it’s easily repeatable.

Furthermore, this knowledge is also applicable for similar user engagement features like updates.

There are a bunch of pitfalls to be aware of while developing:Push notifications aren’t currently supported on voice-activated speakers.

Actions cannot be configured to trigger the Default Welcome Intent from a push notification.

You can send up to 10 notifications per user per day.

Sending notifications is limited to one notification per user per minute.

There may be limitations associated with the chosen language.

Building an Action on Google for a better user engagement using notifications consists of the following steps:Prepare an Intent for notificationsAsk for permissionPush notificationsPrepare an Intent for notificationsGoogle Assistant IntegrationIn Dialogflow, you need to add the intent for notifications to the list for “Implicit invocation” (done via Google Assistant Integration).

This is the “RecentNewsIntent” intent in this sample.

User engagement for Actions on GoogleFurthermore, you need to allow the “User engagement” for notifications for the intent’s related action on the “Actions on Google”-side.

Ask for permissionBefore users can receive push notifications from an Action for the Google Assistant (both via Dialogflow integration and as a plain “Action on Google”), you must show them a suggestion chip to invite them to opt-in for push notifications.

In this sample, this is done on the fulfillment side using Cognigy.

AI in response to the “Default Welcome Intent”.

Requesting permission for notifications inside Cognigy.

AIPayload for requesting permission for notifications.

Then you need to request permission, which is done on the Cognigy.

AI side in response to the “SendNotificationsIntent” (which needs to be defined in Dialogflow).

The response sends a payload shown above (it’s important to have the intent for notifications here).

If the user now permits notifications you get the result through the intent, which listens for the “Google Assistant Permissions” event.

In this sample “FinishNotificationsSetupIntent”.

Finally, you get the result in the “FinishNotificationsSetupIntent” intent in Cognigy.

AI (you can check this via the log).

To finalize the subscription in Cognigy.

AI, you need to save the User ID for the user.

This is passed as argument if the user grants the permission.

Once you have checked the permission, you can simply take the User ID from the Cognigy Input Object {{ci.

userId}}.

Push notificationsTo send notifications with Push Notifications, we need to use Actions API.

But we cannot use the Actions API yet, event though you created your project on Actions on Google and Dialogflow.

You need to make the Actions API available on the Google Cloud Platform .

To enable Actions API, do the following operations:There is a gear icon next to the Dialogflow agent name on the left navigation menu in Dialogflow.

Click the gear icon to open the setting page.

Click the Google Cloud link on the GOOGLE PROJECT.

In the new tab, the Google Cloud Platform Console is opened.

Confirm that the “Notifications” project is selected on the header.

Click the hamburger menu on the top left of the page, then click APIs & Services in the menus.

Then click Dashboard.

Click ENABLE APIS AND SERVICES on the top of the page.

Enter “Actions API” to the Search for APIs & Services field.

Then, the search result will be shown.

In the result, click “Actions API”.

Click the ENABLE button on the description page for Actions API.

To issue a Service Account Key, do the following operations:Click the hamburger menu on the top left of the page, then click APIs & Services in the menus.

Next, click Credentials.

Select Service account key from the Create Credentials pulldown menu.

For the service account, select “New service account”, and fill in the following:Service account name: “notifications”Role: (Project) OwnerKey type: JSONNow, you get a JSON-file with credentials to use the services.

Once you have everything together, you can create your push notifications with a script like:Please note, you need to change the path to your JSON-file containing the credentials.

You also need to change the userId, and you should check the intent name as well.

Usage is simply something like:node .

send-notification.

js "Hello my friend.

" Conclusion and next stepsThis tutorial’s purpose is to simply see and learn how Push notifications for the Google Assistant (Actions on Google) work.

Thanks, to the Conversational AI Platform Cognigy.

AI I could accomplish this task without writing much code.

The official documentation is a good starting point, but I found the tutorial by Yoichiro Tanaka very inspiring every time I got stuck.

By the way, I want to make push notifications even easier and plan to build a custom module for Cognigy.

AI, which lets you send notifications from within a conversation without any hassle.

.. More details

Leave a Reply