This sample demonstrates Actions on Google user engagement features for use on Google Assistant including push notifications and daily updates -- using the Actions SDK, the Actions on Google Java client library, and Google Cloud App Engine.
- Download & install the Google Cloud SDK
- Gradle with App Engine Plugin
- Run
gcloud auth application-default login
with your Gooogle account - Install and update the App Engine component,
gcloud components install app-engine-java
- Update other components,
gcloud components update
- Run
- Install the gactions CLI
- You may need to grant execute permission, ‘chmod +x ./gactions’
- From the Actions on Google Console, New project (this will become your Project ID) > Create project.
- Scroll down > under More options select Actions SDK > keep Use Actions SDK to add Actions modal open
- Install the gactions CLI if you haven't already.
- From Google Cloud console > select your Project ID from the dropdown
- Menu ☰ > APIs & Services > Library > select Actions API > Enable
- Under Menu ☰ > APIs & Services > Credentials > Create Credentials > Service Account Key.
- From the dropdown, select New Service Account
- name:
service-account
- role: Project/Owner
- key type: JSON > Create
- Your private JSON file will be downloaded to your local machine
- name:
- Rename private key file to
service-account.json
and store in thesrc/main/resources/
directory. - In the
src/main/resources/config.properties
file of the project, update the value of theproject_id
field with the project ID of your newly created project
- From the Firebase console, find and select your Actions on Google Project ID
- In the left navigation menu under Develop section > Database > Create database button > Select Start in test mode > Enable
- Configure the gcloud CLI and set your Google Cloud project to the name of your Actions on Google Project ID, which you can find from the Actions on Google console under Settings ⚙
gcloud init
- Deploy to App Engine using Gradle:
gradle appengineDeploy
OR- From within IntelliJ, open the Gradle tray and run the appEngineDeploy task
- Open the
action.json
file:- In the conversations object > replace the placeholder URL values with
https://<YOUR_PROJECT_ID>.appspot.com
- In the conversations object > replace the placeholder URL values with
- In terminal, run
gactions update --action_package action.json --project <YOUR_PROJECT_ID>
- Back in the Actions console, from the Use Actions SDK to add Actions window > select OK from the modal.
- Under Build > Actions
- Select the
Tell a tip
intent > under User engagement > EnableWould you like to offer daily updates to users?
> add a titleadvice Alert
> Save - Select the
Tell the most recent tip
intent > under User engagement > EnableWould you like to send push notifications? If yes, user permission will be needed
> add a titleLatest Info Alert
> Save
- Select the
- In the Actions on Google console > from the top menu click Test.
- Type
Talk to my test app
in the simulator, or sayOK Google, talk to my test app
to Google Assistant on a mobile device associated with your Action's account. - To test daily updates, choose a category. After the tip, the app will show a suggestion chip to subscribe for daily updates. Once a user is subscribed, they will receive update notifications daily for the time they specified.
- To test push notifications, choose to hear the most recent tip. After the tip, the app will show a suggestion chip to subscribe for push notifications. To send a push notification to all subscribed users, enter or say "send notification" at any point during the conversation.
- Questions? Go to StackOverflow, Assistant Developer Community on Reddit or Support.
- For bugs, please report an issue on Github.
- Actions on Google Documentation.
- Getting started with Actions SDK Guide.
- More info about Gradle & the App Engine Plugin.
- More info about deploying Java apps with App Engine.
Please read and follow the steps in the CONTRIBUTING.md.
See LICENSE.
Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.