Pizza Primo Amore, San Daniele e scaglie di Grana @ Pizzeria Hollywood (Treviglio, Italy)

Assistant & … Pizza 🍕 — Dialogflow — Part 2

Build Actions on Google Assistant with Kotlin! — Prepare the environment!

4 min readFeb 7, 2020

--

This article is part of a series “Build Actions on Google Assistant with Kotlin!”
Overview | Dialogflow | Intent | Backend | Tips & Tricks

Dialogflow is a free service (with quotas) by Google that uses machine learning to understand what users are saying.

Dialogflow Console

Create your first Agent

An Agent is a virtual assistant that handles conversations with your users, and it could be the name of your app.

To create an Agent we have to take a few steps:

  • Open https://console.dialogflow.com.
  • Sign in with your Google Account: Dialogflow needs your permission to access your data, so you need to press “Allow” to continue.
  • Once you accept all “Terms & conditions”, you will be presented with the console:
Dialogflow console with no Agents — https://console.dialogflow.com
  • Select “Create Agent” and choose your Agent name, this would be the name of your app — in this example, our agent will be “IncredibleAmazingPizza”
  • In a few seconds, the Agent is “ready to learn” 🎉
Dialogflow console after Agent was created

How does Dialogflow work?

Dialogflow works by matching what a user says with a list of intents: all the user requests could be grouped by intention, this is the Intent of the request. Our Action tries to match the user request to the intents that we define. We should define the complete list of intents that we want to handle.

Example: user says “Margherita ingredients?” and match our Intent “Ingredients”. An alternative request could be “what’s inside the Margherita?” we want that match the same Intent!

On the other hand, an Entity defines a list of possible options for a parameter. An Intent frequently has a list of parameters that we want to extract.

In the previous example “Margherita ingredients?” we would like to extract the name of the pizza. The entity could be “Pizzas”, and the possible options for this Entity are: “Margherita”, “Marinara”, “Prosciutto”, …

Additionally, other key concepts come in handy: the Fulfillment is a bridge between Dialogflow and our service. Whenever parsing the response requires some application logic, we could send the request, with matched Intent and parameters, to our backend.

As Integration, we usually indicate a list of services that could be handled by our Action. For instance, a few famous services require few to no setup: Google Assistant, Facebook Messenger, Slack, Twitter, and Telegram.

Predefined Intent

By default, a few Intents are created to handle basic communication with our users for us. These will be called Predefined Intents.

I suggest trying to interact with our agent before proceeding. On the top-right corner of Dialogflow window, we can find a tool to talk to our Action. We can use it to send a request and see the response while we are developing our Action.

“Try it now” in Dialogflow console

Our Action should handle a few Intents to help us get started:

  • Default Welcome Intent: this Intent is triggered when our Action receives the “Welcome” event. This is the way that allows you to control how conversions will start.

Our Action responds “Hello! How can I help you?” or “Good day! What can I do for you today?”

  • Default Fallback Intent: this Intent is triggered when the user request does not match any other Intent. In this way, we can always respond to the user.

Our Action responds “Could you say that again?” or “Sorry, can you repeat?”

Customize the “Welcome” Intent

The Default Welcome Intent is usually the first approach with our users, and to make a good first impression we should remember a couple of rules:

  • Start with a greeting: try to define an Action’s persona (read docs), and use it in all user interactions. We could start with a formal greetingHello! How can I assist?” or an informal greetingYo! What’s up?”.
  • Let the user take the control: explain very briefly how to start or suggest how the interaction can be brought on by the users.

Now, open Default Welcome Intent and scroll to the Responses section. Here we can customize our responses for this Intent.

Responses example: “Hi! I know the ingredients of the pizzas. Can I help you?”
A good starting point for our Action!

Next step — Off to the quest! 😁

Now Dialogflow is configured, we have a general understanding of what we need to build to make a working Action, and the fun is about to start!

--

--