Skip to content

prav10194/google-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-nodejs

A simple example of integrating google actions with our Node.js application running locally.

Setting up your action in Google

  1. Visit the following link - https://console.dialogflow.com/api-client/#/login.

  2. Click Sign in with Google.

alt text

  1. Click Create Agent on the top left.

alt text

  1. Type in MiniHome and click Create

  2. Now create an intent. Type in as shown. Put intent name also as HomeMini.

alt text

  1. Double tap on whatever you typed in User says and chose the option as @sys.geo-state-us.

alt text

  1. It will look like this -

alt text

  1. Go to fulfillment tab on the left.

alt text

  1. Enable the webhook.

alt text

  1. Enter your ngrok domain followed by /weather. It will look something like - https://xxxx.ngrok.io/weather Setting up ngrok has been explained down.

  2. Click Save at the bottom of the page.

  3. Go to your MiniHome Intent.

  4. At the bottom you will see Fulfillment. Click on it.

alt text

  1. Enable Use Webhook option.

alt text

  1. Go to Integrations Tab on left.

alt text

  1. Click on Google Assistant.

  2. Select What in implicit invocation.

alt text

  1. Click Test.

  2. Keep the new screen open and set up the nodejs application.

Setting up the Node.js application

  1. Clone/Download zip of repository.

  2. Extract content of the zip.

  3. Open cmd to run the following code -

cd "folderpath where zip is extracted"
npm install
  1. After the installation, run -
npm start

Setting up the .env file

  1. You need to register for google geoencoder api from here - https://developers.google.com/maps/documentation/geocoding/get-api-key?authuser=1

Copy the API KEY in the .env file.

  1. You also need to have a bluemix account and should have credentials for the Weather API. You can get it from here - https://console.bluemix.net/catalog/services/weather-company-data

Copy the Username and Password of the SERVICE (as shown in image) in the .env file.

alt text

Setting up the ngrok

  1. In Google Actions, you need an endpoint so that it can connect to your app locally. For this we will install ngrok. Download from here - https://ngrok.com/download

  2. Run your app using npm start as explained above in Setting up the Node.js application.

  3. Open another terminal and run the following command -

ngrok http 8080

8080 is the port number on which your Nodejs app is running.

  1. Copy the Forwarding domain from the ngrok terminal. E.g. Your domain would look something like - https://c90db8b2.ngrok.io

Paste it in the Fulfillment Webhook Configuration.

The final endpoint will be - https://c90db8b2.ngrok.io/weather

Testing

Here is a sample conversation flow using Google Actions -

alt text

You can also test it on your Google Assistant app on your phone.

About

A simple example of integrating google actions with our Node.js application running locally.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published