A simple example of integrating google actions with our Node.js application running locally.
-
Visit the following link - https://console.dialogflow.com/api-client/#/login.
-
Click Sign in with Google.
- Click Create Agent on the top left.
-
Type in MiniHome and click Create
-
Now create an intent. Type in as shown. Put intent name also as HomeMini.
- Double tap on whatever you typed in User says and chose the option as @sys.geo-state-us.
- It will look like this -
- Go to fulfillment tab on the left.
- Enable the webhook.
-
Enter your ngrok domain followed by /weather. It will look something like - https://xxxx.ngrok.io/weather Setting up ngrok has been explained down.
-
Click Save at the bottom of the page.
-
Go to your MiniHome Intent.
-
At the bottom you will see Fulfillment. Click on it.
- Enable Use Webhook option.
- Go to Integrations Tab on left.
-
Click on Google Assistant.
-
Select What in implicit invocation.
-
Click Test.
-
Keep the new screen open and set up the nodejs application.
-
Clone/Download zip of repository.
-
Extract content of the zip.
-
Open cmd to run the following code -
cd "folderpath where zip is extracted"
npm install
- After the installation, run -
npm start
- 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.
- 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.
-
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
-
Run your app using npm start as explained above in Setting up the Node.js application.
-
Open another terminal and run the following command -
ngrok http 8080
8080 is the port number on which your Nodejs app is running.
- 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
Here is a sample conversation flow using Google Actions -
You can also test it on your Google Assistant app on your phone.