Pizza Margherita con cornicione ripieno @ Pizzeria Fofò Mattozzi (Milano, Italy)

Assistant & … Pizza 🍕 — Intent — Part 3

Build Actions on Google Assistant with Kotlin — Create your first Intent, define Entities and parameters!

4 min readFeb 14, 2020

--

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

Previously, we explored how to start a conversation using the Welcome Intent. The next step will be more related to the users and how they will interact with our Action.

Define new Intents

We should recall how the Agent may welcome the user: “Hi! May I help you with pizzas and its ingredients?”

At this point, we foresee the users will most probably want to perform one of the 2 actions:

  • Ask Ingredients: is what we define the happy path, as it’s the main interaction with our Action. Users may ask questions like “what are the ingredients of Margherita?”.
  • Help: can be trigger whenever users don’t know how to proceed and when they want to know what are the possible interactions available.

Intent: Help

As a first step, we want to tackle the Help path. This is the simplest interaction and it will give us a better overview of how to create, manage, and train an Intent!

We start by creating an Intent, which requires us to feed in the following information:

  • Intent name: give it a name that helps us understand the user intention, for example, Help is very clear.
  • Training phrases: we should add all the phrases that could trigger this Intent, for example: “what can you do?”, “can you help me?”, “what can I say?”.
Training phrases — Example for “Help” Intent
  • Responses: this intent requires a very simple response. We just need to explain the functionality of our Action. We could add more than one response, but our users would only receive a randomly picked one each time.
  • Click Save and we are done. 🎉
    To try it, we can click on the top-right section.

Intent: Ask Ingredients

Now that we have a general understanding of how to create a basic Intent, we want to focus on something more challenging. We should handle the Ask Ingredients request.

Once more, we want to feed in the data, in the same way we filled the previous Help Intent:

  • Intent name: Ask Ingredients.
  • Training phrases: we should handle phrases like: “what are Margherita’s ingredients?”.
    In this case, after we match the intent, we want to extract the pizza name and then we can easily use it to generate a response.

Before continue, we should define a new Entity PizzaName that contains our pizzas.

Now we can add the training phrases in our intent.

  • Action and Parameters: we want to extract the PizzaName so we have to parse raw end-user input. If we have already defined an Entity, Dialogflow will automatically highlight the parameter we need to extract, set a default name and the correct type.

In our case, PizzaName is required to answer correctly to the user. We should flag the “Required” field and add a “Prompts” for this parameter.

User says “What are the ingredients?”, our Agent says “which pizza?”

  • Responses: this time we can’t use the predefined responses’ list, we need to customize the responses using the PizzaName parameter, we can do it using a backend service. But, what happens if it’s not available? We should add here the responses for that case.

This is the current flow:

Next step — Define a custom response!

Now that we have our Intent, we could create a custom response with backend service. For example, we could use Google App Engine with Kotlin.

--

--