Push Notifications
Learn more about how to send push notifications to your Google Action users.
Introduction
The Push Notifications feature allows you to send user's notifications, which, if tapped, triggers a predefined intent of your Google Action. To send a push notification, you need to setup the Actions API and configure scenes to handle the individual steps of configuring push notifications.
Configuration
Service Account
Push Notifications will be sent over the Actions API, which you'll need to setup for your Google Cloud project linked to your Conversational Action.
First, go to the Google API Console and select your project. Make sure the project's ID is the same as your Conversational Action's ID. After you selected your project, enable the Actions API.
Next, you'll create a service account with respective credentials, that you'll use to send the notifications to your users.
After you gave your account an appropriate name, choose the Role Project > Owner
, to give your account all necessary permissions. When you're done, go to the Service Account details and add a new key certificate in JSON format, which you can then download and store in your project's directory.
Scenes
To implement Push Notifications in your voice application, we recommend using scenes to handle the setup.
There are multiple ways of setting up the scenes necessary, we recommend creating them inside your model file to deploy them directly to the Google Conversational Actions Console.
These two scenes, located inside your Jovo model, determine how to set-up Push Notifications.
PushNotificationsScene
propagates the request to PushNotificationsScene_Notifications
, if the intent PushNotificationsIntent
has been triggered by the user, where the user will be asked whether to opt in or out of push notifications.
In order for your action to listen for PushNotificationsIntent
, you need to instruct your Google Action to handle the next conversation step with the specified scene:
ON_PERMISSION
After the user has responded to your request, you will receive a request to notify you about the result, which will be mapped to the Jovo built-in ON_PERMISSION
intent:
Sending the Notification
Using the class PushNotificationsApi
and your credentials, you can now send a push notification: