Monday, April 16, 2018

Developing a Google Assistant app using NodeJs, Dialogflow and Firebase Functions - Part 1

What is Google Assistant?

Google Assistant is a virtual personal assistant developed by google available on variety of devices like mobile phone, smart home device, on a smart watch or on a TV or even the web. It can engage in two way conversations and can work entirely with voice. 

What can it do?

With the assistant, you can control smart home devices, do most of the functions on your phone like placing a call, sending a text etc with just your voice, play content and also interact with apps. It also has routines which is a sequence of things which can be done with a single command. So existing content can be packaged into an assistant app or apps can be built without writing any code using templates or by writing custom apps. 

How to develop custom apps for Google Assistant?

For more flexibility we can also develop apps using the APIs provided by Google. There are two APIs we can use are Actions SDK and Dialogflow 
Using the actions SDK, your app can perform actions. An action defines an entry point into your app’s functionality and maps an intent that describes the action to the fulfillment that processes the intent. The fulfilment gets the user input as string, processes the input and provides a response. This interaction continues back and forth till the action is complete. 
Dialogflow is a conversational platform that lets you design and build actions by wrapping the functionality of the Actions SDK and providing additional features such as an easy-to-use IDE, natural language understanding (NLU), machine learning, and more. So it sits above the actions SDK and works with actions SDK. 

Developing the App

Here I will show how to create an app called InspireMe using the Dialogflow API. User can talk to this app to get inspirational quotes and passages. 

The flow of the app works like this 

User specifies an intent to Google Assistant or explicitly asks for taking with the app - > The welcome intent of the app is triggered - > Fulfilment is triggered for the intent - > Fulfilment picks a quote and returns in the response - > That quote is played in the response -> User is given an option to listen another quote or end the conversation - > If user selects Yes -> another quote is picked and played -> when user says no -> App wishes user a good day and the flow ends. 

The steps to create the app are

1. Create an actions on google project. Save your app name and details
2. Build the project on dialogflow
3. On the dialogflow console, setup the intents for the app and enable fulfilment.
4. Handle the intent fulfilment webhook requests and return responses to the user.

The next steps for creating the app will are covered in part 2 here.

No comments:

Post a Comment