People in Space Google Assistant App

Matt Carroll Oct 11, 2017

Disclaimer: I work at Dialogflow where it’s my job to make developing apps for conversational interfaces as easy as possible and I’ve built a few before, but I really did go from an idea to a submission for this Assistant app in 50 min with all the same tools and code you can use.



I’ve been working on a lot of Dialogflow and Google Assistant samples lately and wanted to finish one, but most of the samples that I wanted to do and are currently working on were large, complex and would require quite a lot of work and polish to be ready for submission (VUI and designing conversations are hard!). Below is a log of what I did that I reconstructed using my terminal logs, browsing/Chrome/Google history, Google Cloud/Firebase project history and logs, and file metadata (if you want to skip to the code I wrote it’s here):

11:20 PM I remember a cool API that I wanted to do a project while that is very simple: that tells people how many people there are in outer space (which, these days, means the international space station). I search on Google and find it right away: http://open-notify.org/Open-Notify-API/People-In-Space/

11:21 PM I create a new Dialogflow agent called people-in-space (which conveniently creates a Google Cloud project for our app too) and start clicking around figuring out how I want to structure my agent. I quickly settle on only supporting telling users the number of people in space and ending the conversation, leading me to just have one intent, the welcome intent, that will use the webhook for fulfillment.

11:23 PM I take a sample that I’ve built before and copy the contents of the directory into a new folder called people-in-space. I’m using this sample because its very simple and calls a HTTP API without any libraries

11:24 PM I look at the People In Space API docs and start making changes to the function that calls an external API to call the People in Space API instead, there isn’t any authentication or even an API key and the JSON structure is very simple:

People in Space API JSON

I also change the response that’s sent to our users to give a proper response for the app: “Currently there are ${numPeopleInSpace} people in space.”

11:28 PM I find out this sample uses Cloud Functions instead of Cloud Functions for Firebase (Firebase didn’t have functions when I originally wrote the sample). So I took a look at another sample I wrote with Cloud Functions for Firebase and copy-pasted the function definition line and that package.json file to my app and change the variable names and package.json description/title.

11:36 PM I try to deploy my function to Firebase but I forget to run npm install so this fails. I figured it out (ok, I didn’t “figure it out” Firebase just told me to run npm install) so I ran npm install inside the function directory to install the Firebase functions library

Firebase CLI Deploy

11:37 PM while npm is installing things I start cleaning up the Dialogflow agent and add the URL for where the function will be once it’s deployed to the Dialogflow agent’s fulfillment section and enable the Google Assistant integration. I also open up the Action console simulator so I can test once I’ve deployed my function properly

11:40 PM I deploy my Cloud Function for Firebase (successfully) for the first time which takes a minute or so… (no errors, yay!)

11:42 PM I try to test it in the simulator but it doesn’t work (the simulator says my app is “unavailable”)

11:43 PM I open up the Firebase logs to see what happen and notice that I haven’t enabled billing for this project so I can’t access external networks (read: call the people in space API)

Firebase Function Debug

11:44 PM I link my Firebase project to my (already existing) billing account so my Cloud Function for Firebase can call external APIs like the People in Space API

11:45 PM The simulator still doesn’t work and still says my app is “unavailable”

11:46 PM I figure out that I somehow missed the checkbox for Use webhook in the fulfillment section and once checked everything works how I expected it would on the simulator (woohoo!). I also give it a try on my Google Home Mini logged into the same Google account and it works too!

Dialogflow Fulfillment Checkbox

11:47 PM I open up the Actions console again and start filling out the information needed to submit the app: name, pronunciation, introduction, TTS voice, descriptions and sample invocation

Action Console

11:51 PM I searched for “space” and “people in space” in the Explore section of the Google Home app to see if anyone else had already built this (they hadn’t but there are a few cool space Assistant apps!)

11:53 PM I start looking for photos for the Assistant app banner (I just searched Google Images for royalty free images with queries like “people in space”, “iss” and “stars”)

11:56 PM Found a couple images (they both happened to be from Wikimedia, thanks Wikimedia!) I was happy with and downloaded the pictures and then uploaded them to the Actions console

11:59 PM I start trying to figure out the privacy policy inside the action template (it’s required) and search for examples of privacy policies on Google

12:02 AM I figured out my privacy policy by pasting the Better Business Bureau privacy policy template into a Google doc, modifying it for my app, making the Google doc public, and pasting in the URL in the Actions console (since I don’t actually log anything for this app it’s fairly simple)

12:09 AM did my final check that the Assistant app works in the simulator by testing the draft

Action on Google Simulator

12:10 AM clicked submit draft for approval and opened a Google doc to write this blog post!

And there you have it, from idea to a working, submitted Google Assistant app in exactly 50 min! You can checkout the code on Github here. You can also try the Assistant app out on any device that has the Google Assistant by saying or typing “Talk to People in Space”. In the future I’d like to add support for multiple intents, be able to answer user questions like “Who is in space right now?” (the API gives the names of the astronauts!), and add information about previous days and the international space station.

Have an idea for a Google Assistant app? There is some cool swag for devs who build on the platform like credits for Google Cloud, t-shirts, etc. you can take a look at the what I wrote on Github or check out the official getting started guide to get going.

I’d definitely recommend starting with Dialogflow (but I am a little biased, it’s what I work on!), it makes getting started, determining a user’s intent, extracting parameters and entities and controlling how a conversation progresses a breeze! There is also an integration with Cloud Functions for Firebase which means you don’t have to do any of the Firebase CLI setup or even touch a command line to get your code deployed.