Actions on Google: Updates API sample using Node.js and Cloud Functions for Firebase
This sample shows an app that gives tips about developing apps for the Google Assistant using Actions on Google.
Setup Instructions
Steps
-
Use the Actions on Google Console to add a new project with a name of your choosing and click Create Project.
-
Click Skip, located on the top right to skip over category selection menu.
-
On the left navigation menu under BUILD, click on Actions. Click on Add Your First Action and choose your app's language(s).
-
Select Custom intent, click BUILD. This will open a Dialogflow console. Click CREATE.
-
Click on the gear icon to see the project settings.
-
Select Export and Import.
-
Select Restore from zip. Follow the directions to restore from the
AoG-Tips.zip
file in this repo. -
Go to the Google Cloud Platform console to activate the Actions API, and select the project that you have created on the Actions on Google console. Then, click the Enable button.
-
Go to the Firebase console and select the project that you have created on the Actions on Google console.
-
Click the gear icon, then select Project settings > SERVICE ACCOUNTS.
-
Generate a new private key and save it in the
functions
folder calling the fileservice-account.json
. -
On the left navigation menu under DEVELOP, click on Database.
-
Under Cloud Firebase Beta, click Get Started.
-
Select Start in test mode, click Enable.
-
In the
functions
directory, deploy the fulfillment webhook provided in the functions folder using Google Cloud Functions for Firebase:- Follow the instructions to set up and initialize Firebase SDK for Cloud Functions. Make sure to select the project that you have previously generated in the Actions on Google Console and to reply
N
when asked to overwrite existing files by the Firebase CLI. - Run
npm install
to install dependencies. - Run
firebase deploy
and take note of the endpoint where the fulfillment webhook has been published. It should look likeFunction URL (aogTips): https://${REGION}-${PROJECT}.cloudfunctions.net/aogTips
- Follow the instructions to set up and initialize Firebase SDK for Cloud Functions. Make sure to select the project that you have previously generated in the Actions on Google Console and to reply
-
Go back to the Dialogflow console and select Fulfillment from the left navigation menu. Enable Webhook, set the value of URL to the
Function URL
from the previous step, then click Save. -
To add tips to the newly created Firestore database, load in a browser
https://${REGION}-${PROJECT}.cloudfunctions.net/restoreTipsDB
. -
Go to the Actions on Google console.
-
Follow the Console Setup instructions in the Daily Updates and the Push Notifications documentation to enable daily updates and push notifications.
-
Type
Talk to my test app
in the simulator, or sayOK Google, talk to my test app
to any Actions on Google enabled device signed into your developer account. -
To test daily updates, choose a category. After the tip, the app will show a suggestion chip to subscribe for daily updates.
-
To test push notifications, choose to hear the latest tip. After the top, the app will show a suggestion chip to subscribe for push notifications. Add a new tip to the Firestore DB to trigger a notification to the subscribed users.
For more detailed information on deployment, see the documentation.
References and How to report bugs
- Actions on Google documentation: https://developers.google.com/actions/.
- If you find any issues, please open a bug here on GitHub.
- Questions are answered on StackOverflow.
How to make contributions?
Please read and follow the steps in the CONTRIBUTING.md.
License
See LICENSE.md.
Terms
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.
Google+
Actions on Google Developers Community on Google+ https://g.co/actionsdev.