Welcome to “How To Set up Google Assistant Trivia Game In Detail” part 2. Here is the part 1 in case you miss it.
STEP II: Deploy the fulfillment Webhook provided in the functions folder using Google Cloud Functions for Firebase and the static resources needed by the project using Firebase Hosting:
- Open the file functions/index.js and find the declaration of the HOSTING_URL constant at the top. Replace the ‘<YOUR_PROJECT_ID>’ placeholder with the Project ID of the Firebase project, that you can find in the general settings page of your project in the Firebase Console.
For instance, the final value of HOSTING_URL should look like https://mytriviagame-3772e.firebaseapp.com. (Note: your project ID can be different.)
- Follow the instructions to install the Firebase CLI.
Install Firebase CLI in your local machine (through Terminal for Mac and Command Prompt for Window):
Important note: before executing any other following commands, make sure you change the directory (using cd <path> command) to the directory path that you just extracted (apiai-trivia-game-nodejs-master).
Login to Firebase:
Go back to Terminal or Command prompt, and run Firebase init command, then choose to configure Hosting and Functions. (Press tab to select and use arrow key to navigate).
firebase initcommand will create a
firebase.jsonsetting file in the root of your project directory.
- If you want to customize the database with your own questions and prompts, you can modify them in questions.json and prompts.json.
- Generate a private key using Firebase Settings/Service Accounts, and edit functions/database.js file with the path to the JSON certificate file.
- Deploy the trivia game project to Firebase
Run Firebase deploy and take note of the endpoint where the fulfillment Webhook has been published. It should look like Function URL (triviaGame): https://us-central1-mytriviagame-3772e.cloudfunctions.net/triviaGame.
The command will also deploy the static assets at https://us-central1-mytriviagame-3772e.cloudfunctions.net/ .
Just Kidding 🙂 We are not going to write any unit tests. The goal here is to test our trivia game through the simulator in Actions on Google.
- In the API.AI console, select Integrations from the left navigation menu and open the Settings menu for Actions on Google.
- Click Test.
- Click View to open the Actions on Google simulator.
Voilà, now the setup for Trivia Game for Google assistant platform is completed. You can try out the game in the simulator.
Where to go from here
- Customized Small Talk feature in API.AI
What happens if users type or say common questions/requests such as How are you? Who are you? etc. In API.AI, such questions can be customized in Small Talk. It is a module in API.AI console that can be found in the left navigation menu; It allows us to customized responses to the most popular request.
- Test on devices
On a supported device, such as the Google Home or an Android phone, log into the device with the same account that you used to create your Actions on Google developer project.
Finally, create your own trivia games and submit your app to Actions on Google for approval. Why not? 🙂