This sample demonstrates Actions on Google user engagement features for use on Google Assistant including push notifications and daily updates -- using the Java client library and deployed on App Engine.
- Download & install the Google Cloud SDK
- Gradle with App Engine Plugin
- Run
gcloud auth application-default login
with your Google account - Install and update the App Engine component,
gcloud components install app-engine-java
- Update other components,
gcloud components update
- Run
- From the Actions on Google Console, New project (this will become your Project ID) > Create project > under More options > Conversational.
- From the top menu under Develop > Actions (left nav) > Add your first action > BUILD (this will bring you to the Dialogflow console) > Select language and time zone > CREATE.
- In Dialogflow, go to Settings ⚙ > Export and Import > Restore from zip.
- Follow the directions to restore from the
agent.zip
file in this repo.
- Follow the directions to restore from the
- 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 Dialogflow console under Settings ⚙ > Google Cloud link
- In the Cloud console, go to 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.
- 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
- From the Actions on Google console > under the top menu Develop > Actions (left nav):
- Select the
tell_tip
intent > under User engagement > EnableWould you like to offer daily updates to users?
> add a titleAdvice Alert
> Save - Select the
tell_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
When a new project is created using the Actions Console, it also creates a Google Cloud project in the background.
- 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.
- Return to the Dialogflow Console, from the left navigation menu under Fulfillment > Enable Webhook, set the value of URL to
https://${YOUR_PROJECT_ID}.appspot.com
> Save. - From the left navigation menu, click Integrations > Integration Settings under Google Assistant > Enable Auto-preview changes > Test to open the Actions on Google simulator then say or type
Talk to my test app
.
- In the Dialogflow console, from the left navigation menu > Integrations > Integration Settings under Google Assistant > Enable Auto-preview changes > Test to open the Actions on Google simulator.
- 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, type "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
- Webhook Boilerplate Template for Actions on Google.
- 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.