In the previous article, we have see the basics of Google Assistant and Actions On Google, we have also seen the difference between them. (If you have missed it, check Basics of Google Assistant and Actions On Google)
What you will learn
- Create an Actions project.
- Integrate DialogFlow with Actions project.
- Create a DialogFlow Intent.
- Testing application with Actions simulator.
Let’s move to the first step of creating our google assistant application
Create an Actions project
Open a google actions console in your browser and sign-in with your google account. Once you are signed in, you will be able to see the following screen in your browser.
Click on Add/Import project and agree to the terms and condition of Action on Google.
It will ask for the project name, enter your project name and click on Create Project.
As you can see in above image, the project name is Cricket Facts. Using this assistant application, user will be able to know few known/unknown facts about cricket.
Once you are done with creating a project, you will be able to see the following screen.
We are done with creating our first project on actions console. Now click on Actions on Google available in top left corner which will redirect you to home page.
As you can see, now you have a project named Cricket Facts in your project list. Click on it and we will move to further steps.
Integrate DialogFlow with Actions project.
From the left-hand menu click Build > Actions > ADD YOUR FIRST ACTION. Then select Custom Intent > BUILD
It will redirect you to DialogFlow console. DialogFlow will ask for the permission for your account, read all those for your understanding and click on Allow.
If it is the first time you are acccessing DialogFlow, it might ask you to review account settings and terms of service. Read it carefully and click Accept.
Now you will be redirected to DialogFlow agent creation page.
You might have observed that agent name is prefilled which is our project name that we have entered, click on Create. Now we will move forward and create first Intent for our application.
Create a DialogFlow Intent.
From the left side menu panel select Intent and click on CREATE INTENT and enter our first intent name Facts Generator.
Now click on ADD TRAINING PHRASES and add following phrases :
- What are facts
- Tell me about cricket facts
- What are known/unknown facts
- Cricket facts
These are the supposed inputs from the users, so we can add as many as we can.
Now click on ADD RESPONSE and enter below responses :
- Chris Gayle is the only batsman to hit a six off the first ball of a Test match
- Vinod Kambli’s Test match average is better than his childhood friend Sachin Tendulkar
- Sunil Gavaskar was out off the first ball of a Test match thrice in his career
- The only cricketer to play Test cricket for India and England is Saif Ali Khan’s grandfather, Iftikhar Ali Khan Pataudi
- Asif Karim of Kenya has played International cricket and Davis Cup (Tennis) for his country
As of now, we will keep 5 facts, you can add as many as you want.
Now click on Save in the top right corner.
Testing application with Actions simulator.
For this step, you first need to check whether you have given necessary permissions or not. Open Google Activity Controls page and enable below permissions.
- Web & App Activity
- Device Information
- Voice & Audio Activity
Once you are done with it, move back to your Actions on Google console. Select Test from the menu and you will be on test Simulator.
To test your actions, hit the Enter key in the box written Talk to my test app or click on the chips given below Suggested Input.
Now enter any of the training phrases that we have entered earlier. For example, enter Tell me about cricket facts
From the response, you have got an idea that how it works. Now enter training phrases and responses of your choice from the DialogFlow console and test it with the simulator as many times as you want.
Congratulations! You have just finished building your first Google Assistant application and now you are ready to publish it. To publish it over market check How To Publish Google Assistant Application.