Last month we brought Artsy to Amazon Alexa. In this post we'll repeat that process and enable Artsy for Google Assistant, including Google Home.
tl;dr You can try Artsy on your Google Home now, say "Ok Google, talk to Artsy" or see assistant.artsy.net for more info.
Actions are two-way dialogs with users. A user invokes an action, which calls so-called fulfillment code - a REST endpoint.
If you've never worked with Google Actions, read the conversation actions intro.
To write an action get the actions SDK, which is a node.js client library, describe the actions in JSON and use a command-line tool called
gactions or a web simulator to invoke the action code.
action.json that describes the actions, including the invocation trigger for each action and the text-to-speech voice for the agent to use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
The action implementation lives in
lib/action.js that imports and creates a new instance of
google-actions-server, binds intents to functions and issues questions with
agent.ask or sends final responses with
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
GAS does a good job at enabling running of a local development version.
ngrokto proxy requests to the outside world.
npm run serverto start the local instance.
- Deploy a preview version of the app with
npm run action:autopreview.
npm run action:simulatefor a local simulator, use the web version or even a Google Home device registered under your development account.
The certification process requires that you deploy the node.js application into a production environment, first. We deployed ours into Google Cloud, which involved creating a
vm.yaml, creating a new deployment with
npm run build and deploying the app with
gcloud app deploy. You can just push the app to Heroku or AWS Lambda as well.
Google Actions API Project
Create a Google Actions API project from the API Dashboard and configure the project in "Directory Listing". It's important to get the sample invocations right, eg. "Ok Google, ask my first action to ...".
Deploying the action makes it usable by others by submitting it for approval with Google. Once submitted you have to wait for your action to be rejected or approved, there's no way to un-submit an action without contacting support.
httpExecution URL(s) in
action.json to the deployed fulfillment URL, eg.
https://my-first-action.appspot-preview.com, ensure the correct action ID is used in
package.json, and run
npm run action:deploy, which will register and deploy your action.
The application will appear under "Deployment History" in the API dashboard.
Find the complete source code on Github.