/ga-collection-stalbans

Google Assistant Action to display the next Recycling and Refuse collection in St Albans

Primary LanguageJavaScript

Google Assistant Collection St Albans

Google action that can be invoke from your Google device to display the next Recycling and Refuse collection for St Albans.

alt text

##Setup Google Actions

  1. Go to https://console.actions.google.com/
  2. Create a new project ( I used ga-collection-stalbans )
  3. Select Games & Fun ( at the moment is the only type that allows interactive canvas)
  4. Select type of Conversational
  5. Decide the invoke key
  6. Go to Deploy and enable Interactive Canvas
  7. Add a new action, press Get Started and select Play Game
DialogFlow
  1. Choose your agent's name ( I used ga-collection-stalbans )
  2. Go under Setting and Export & Import
  3. Restore the zip file actions.zip
Firebase
  1. Go to https://console.firebase.google.com/
  2. Select your project
  3. You have to change to Blaze plan due to external API call, but it wont charge you if you dont use too much, have a look at the pricing.
  4. Go under Setting and copy your project ID
  5. Run
firebase login
  1. Run
firebase use <project id>
Dependency
  1. Run
npm install 

in the root folder 2) Run

npm install

in the function folder 3) Run

npm run build 

to build the website 4) Run

firebase deploy
Update links
  1. Once you run firebase deploy, go back to firebase page ( https://console.firebase.google.com/ )
  2. In functions, copy the link
  3. Go back to https://dialogflow.cloud.google.com/
  4. In Fulfillment, enable webook and input the url link
  5. Copy the hosting url and update the variable URL in functions/index.js
  6. Save and run deploy again
Test it
  1. Open https://console.actions.google.com/ and go to test

Screenshots

alt text alt text alt text

Commands

Run server
npm start
Build website
npm run build 
Deploy
firebase deploy

Intents

Clear

Clear the user storage

Collection

Invoke the main script to pull the new date from the API

Collection search

Search for the address and retrieve the UPRN code

Collection setup

Finalise the setup with the UPRN code

Fallback

Trigger whatever the action is not reconising the command

Welcome

Invoke the main script

ISSUES

You might get this error that is common due to npm not installing the developer package

HtmlResponse is not supported on this device..

To fix it, install

npm install actions-on-google@preview 

Another fix is to make sure Interactive Canvas is enable in https://console.actions.google.com/

TODO

  • Cache data and dont pull each time