Actions SDK Conversational Quickstart
- 3 minutes read - 430 wordsGoogle’s tutorial didn’t work for me.
In this post, I’ll help you get this working.
https://developers.google.com/assistant/conversational/quickstart
Create and set up a project
This mostly works.
I recommend using the Actions Console as described to create the project.
I chose “Custom” and “Blank Project”
You need not enable Actions API as this is done automatically:
For the console work, I’m going to use Google’s excellent Cloud Shell. You may access this through the browser or through a terminal:
gcloud alpha cloud-shell ssh
From within Cloud Shell, we need to login using gcloud
. Be sure to complete the OAuth flow:
gcloud auth login
Then set an environment variable for your project, associate it with a billing account, and enable the Cloud Build:
PROJECT=[[YOUR-PROJECT-ID]]
BILLING=$(gcloud beta billing accounts list --format="value(name)")
gcloud beta billing projects link ${PROJECT} \
--billing-account=${BILLING}
gcloud services enable cloudbuild.googleapis.com \
--project=${PROJECT}
Install the gactions command-line tool
Do this as described.
In Cloud Shell, I installed this in ${HOME}
:
wget \
https://dl.google.com/gactions/v3/release/gactions-sdk_linux.tar.gz \
--output-file gactions-sdk_linux.tar.gz
tar xvf gactions-sdk_linux.tar.gz
PATH=${PATH}:${HOME}/aog_cli
gactions version
3.0.0+316143447
No need to do the chmod
.
Get the hello world sample
Do this as described. It’s not ‘hello world’ but called “Interactive canvas sample”:
gactions init interactive-canvas \
--dest interactive-canvas-sample
- interactive-canvas-sample/sdk/settings/settings.yaml replace
<PROJECT_ID>
with the value of${PROJECT}
- interactive-canvas-sample/sdk/webhooks/ActionsOnGoogleFulfillment/index.js replace
https://PROJECT_ID...
with `https://${PROJECT}…
You can:
cd ./interactive-canvas-sample
sed --in-place \
"s|<PROJECT_ID>|${PROJECT}|g" \
./sdk/settings/settings.yaml
sed --in-place \
"s|https://PROJECT_ID.web.app|https://${PROJECT}.web.app|g" \
./sdk/webhooks/ActionsOnGoogleFulfillment/index.js
Deploy and test the sample
cd ./interactive-canvas-sample
firebase deploy --project=${PROJECT} --only=hosting
Yields:
=== Deploying to '${PROJECT}'...
i deploying hosting
i hosting[${PROJECT}]: beginning deploy...
i hosting[${PROJECT}]: found 9 files in public
✔ hosting[${PROJECT}]: file upload complete
i hosting[${PROJECT}]: finalizing version...
✔ hosting[${PROJECT}]: version finalized
i hosting[${PROJECT}]: releasing new version...
✔ hosting[${PROJECT}]: release complete
✔ Deploy complete!
Hosting URL: https://${PROJECT}.web.app
You should be able to browse the function too on that hosting URL:
You may list the function two ways:
firebase projects:list
✔ Preparing the list of your Firebase projects
┌─────────────────────────────┬─────────────────────────────┬────────────────┬──────────────────────┐
│ Project Display Name │ Project ID │ Project Number │ Resource Location ID │
├─────────────────────────────┼─────────────────────────────┼────────────────┼──────────────────────┤
│ ${PROJECT} │ ${PROJECT} │ 123456789012 │ [Not specified] │
└─────────────────────────────┴─────────────────────────────┴────────────────┴──────────────────────┘
Or:
gcloud functions list --project=${PROJECT}
NAME STATUS TRIGGER REGION
cf-beVXlEiFGhXOspUjLiBNgQ-name OFFLINE HTTP Trigger us-central1
Then, from within the sdk
subdirectory:
cd sdk
gactions push
gactions deploy preview
You should receive a ✔ Done.
and you may then browse:
http://console.actions.google.com/project/${PROJECT}/simulator?disableAutoPreview
And you want to type Talk to Interactive canvas sample
(not what the documentation says):
And then you can type, e.g. red
:
Hope that helps!
Tidy
When you’re done, you may delete the project entirely to clear up all the resources:
gcloud projects delete ${PROJECT}