Hello Devz,
Having a Google Home at home and a Google Assistant in my pocket, I wanted to go further and create my own Actions. Pretty easy with Google DialogFlow!
DialogFlow is a free web interface that allows you to create a, wait for it… dialog flow!
Let’s say I want to add an expense by voice. Go to dialogflow.com, create your new project and open the Intents. As you can see, two default Intents will be present: the fallback and the welcome ones. Which will manage the default interactions with the user. Like “Hello”, “I ‘don’t know”, …
![Create Dialogflow Intent](https://code.4noobz.net/wp-content/uploads/2018/05/2-Create-Intent.png)
Create Dialogflow Intent
You can try the default interactions with these intents:
![Test default Welcome Intent](https://code.4noobz.net/wp-content/uploads/2018/05/3-Test-default-Welcome-Intent-174x300.png)
Test default Welcome Intent
Now we can add our own custom Intent. Let’s call it AddExpense. Here we can first add some training phrases. You will see that some words will take colors. An AI is helping you to recognize the default entities, like currencies, date, time, …
![Intent - Training phrases](https://code.4noobz.net/wp-content/uploads/2018/05/4-Intent-Training-phrases-184x300.png)
Intent – Training phrases
If you click on one of the training phrases, you will see the parameters:
![Google Dialogflow - Intent Parameters](https://code.4noobz.net/wp-content/uploads/2018/05/5-Parameters-300x99.png)
Google Dialogflow – Intent Parameters
A bit below, you can see the parameters configuration. You can specify that some parameter are required and a default prompt if it’s missing.
![Google DialogFlow - Intent Parameters configuration](https://code.4noobz.net/wp-content/uploads/2018/05/6-Parameters-configuration-300x85.png)
Google DialogFlow – Intent Parameters configuration
As you can see, you can put as many prompt you want:
![Google Dialogflow - Parameter prompt](https://code.4noobz.net/wp-content/uploads/2018/05/7-Parameter-prompt-300x266.png)
Google Dialogflow – Parameter prompt
When the AI have all the needed parameters, it can give a custom answer to the user:
![Google DialogFlow - Answer](https://code.4noobz.net/wp-content/uploads/2018/05/8-Answer-300x251.png)
Google DialogFlow – Answer
Now if you need more than the default parameters, you can create them in the Entities part. In this example, I will add a PaymentType (cash, credit card, … and their synonyms):
![Google DialogFlow - Custom Entities](https://code.4noobz.net/wp-content/uploads/2018/05/9-Custom-Entities-300x160.png)
Google DialogFlow – Custom Entities
Now you can test you Intent to see if everything works:
![Google DialogFlow - test Intent](https://code.4noobz.net/wp-content/uploads/2018/05/10-test-Intent-91x300.png)
Google DialogFlow – test Intent
Your Intent is complete, a JSON file is generated and can be sent to any webservice, even “locally” in the Google Cloud as a Fullfillement.
![Google DialogFlow - json result](https://code.4noobz.net/wp-content/uploads/2018/05/11-json-result-282x300.png)
Google DialogFlow – json result
![Google DialogFlow - fullfillement](https://code.4noobz.net/wp-content/uploads/2018/05/12-fullfillement-300x174.png)
Google DialogFlow – fullfillement
Now you can integrate your AI to all kind of chat like application:
![Google DialogFlow - Integrations](https://code.4noobz.net/wp-content/uploads/2018/05/13-Integrations-293x300.png)
Google DialogFlow – Integrations
Happy DialogFlow!! 😉