Quickstart: Agent building and interaction using the console

This quickstart shows you how to use the Dialogflow Console to build a simple agent and interact with it.

Before you begin

You should read the Dialogflow basics guide before attempting this quickstart.

Set up your GCP project and authentication

Create an agent

Intents

Intents are used to categorize a user's intentions and map user input to actions and responses. For each agent, you define many intents. For a basic intent, you define:

  • Examples of possible end-user expressions that can trigger a match for the intent
  • Specific types of data to extract from the end-user expression
  • Responses

Default intents

Go to the intent list in agent settings:

  1. Go to the Dialogflow Console.
  2. Select the agent you just created.
  3. Click the agent settings settings button next to the agent name.
  4. If Intents is not selected on the left sidebar menu, click Intents.

The middle of the console shows the list of default intents for the agent. Your agent matches the Default Fallback Intent when it doesn't understand what your users say. The Default Welcome Intent greets your users.

Try it in the simulator

The Dialogflow simulator is on the right side of the console. With the simulator, you can try your agent by speaking or typing messages.

Try the agent now:

  • Click the Try it now field
  • Type something
  • Press enter

You just spoke to your Dialogflow agent! You may notice your agent didn't understand you. Since your input didn't match any intent, the default fallback intent was matched, and you received one of the default replies.

Create and train a new intent

For each intent, you define many training phrases. A training phrase is an example of what a user might type or say to your agent, also known as an end-user expression. For example, a user might ask "what is your name?", "do you have a name?", or just "name?". Each of these end-user expressions are unique but have the same intention: to get the name of your agent.

Create an intent to handle this scenario by following these steps:

  1. Click the add intent add button next to Intents in the left sidebar menu.
  2. Enter name in the Intent name field.
  3. In the Training Phrases section, click the empty text field. Enter the following, pressing enter after each entry:

    • What is your name?
    • Do you have a name?
    • name
  4. In the Responses section, click the text field and enter:

    • My name is Dialogflow!
  5. Click the Save button and wait until the Agent Training popup indicates that training is complete.

Try it in the simulator

In the simulator, type What's your name? and press enter.

Your agent responds to the query correctly, even though your query was a little different from the training phrases you supplied. It was able to resolve this by using machine learning.

Dialogflow uses training phrases as examples for a machine learning model to match user queries to intents. The model checks the query against every intent in the agent, gives every intent a score, and the highest scoring intent is matched. If the highest scoring intent has a very low score, the fallback intent is matched.

Extract data with entities

You can annotate your training phrases with entities, which are specific types of data that you want Dialogflow to extract from end-user expressions. Dialogflow extracts matched entities as parameters from the training phrases.

Add parameters to your intents

To create a new intent with parameters:

  1. Click the plus add button next to Intents in the left sidebar menu.

  2. Name the intent Languages at the top of the intent form.

  3. Add the following training phrases:

    • I know English
    • I speak French
    • I know how to write in German
  4. Click Save.

Dialogflow automatically detects parameters in training phrases that are recognized as system entities. These are entities provided by Dialogflow for many common data types like location, color, and date.

Below the Training phrases section, Dialogflow creates a row in the Actions & parameters table:

  • Required: The checkbox is not checked, so this parameter is optional.
  • Parameter Name: This parameter is automatically named "language", because the parameter is recognized as a language.
  • Entity: This is the entity type. It is recognized as a @sys.language system entity.
  • Value: This is the identifier you use when referencing the value of this parameter.
  • Is List: The checkbox is not checked, so the parameter is not a list.

Use parameter data in a response

The value of a parameter can be used in your responses. In this case, you can use $language in your responses, and it will be replaced with the language specified in the user query.

In the Responses section, add the following response and click the Save button:

  • Wow! I didn't know you knew $language

Try it in the simulator

In the simulator, query your agent with I know Russian.

You can see that Dialogflow correctly extracts the language parameter with the value "Russian", and "Russian" was correctly inserted where the parameter value was used in the response.

Create your own entities

In most cases, you have specific data you need to gather from users that isn't provided by system entities. You can create developer entities to handle this.

To create a developer entity:

  1. Click the add entity add button next to Entities in the left sidebar menu.
  2. Enter ProgrammingLanguage for the name of the entity.
  3. Add the following entity entries (rows):

    Reference Value Synonyms
    JavaScript JavaScript, js, ECMAScript
    Java Java
    Python Python, py
  4. Click Save.

Each entity must have the following:

  • Name
  • One or more entity entries
  • Reference value and one or more synonyms for each entity entry

Dialogflow can handle simple things like plurality and capitalization, but you should add all possible synonyms for your entries. The more you add, the better your agent can determine your entities.

Use your new entity

Add training phrases to the "Languages" intent that make use of the new entity:

  1. Click Intents in the left sidebar menu.

  2. Click the "Languages" intent.

  3. Add the following training phrases:

    • I know javascript
    • I know how to code in Java
  4. Notice that the programming languages in these training phrases are automatically annotated and added to the list of parameters.

  5. In the Responses section, add $ProgrammingLanguage is cool.

  6. Click Save.

Try it in the simulator

In the simulator, query your agent with I know how to code in py.

You can see that Dialogflow correctly extracted the entity py, identified it as the Python entity, and inserted the value in the response.

Manage state with contexts

Dialogflow contexts are similar to natural language context. If a person says to you "they are orange", you need context in order to understand what they are referring to. Similarly, for Dialogflow to handle an end-user expression like that, it needs to be provided with context in order to correctly match an intent.

Normally, Dialogflow matches an intent if its training phrases closely resemble an end-user expression. However, when you apply contexts to an intent, Dialogflow will only consider that intent for matching if the context is active. Using contexts, you can control the flow of a conversation by defining required conversation states for an intent to match. You can also carry information from one matched intent to the next.

Add a follow-up intent

Follow-up intents provide a simple way to control a conversation without having to create and manage contexts manually. These special intents are nested under their parent intent. Dialogflow provides pre-defined follow-up intents that are designed to handle common replies from the user, like "yes", "no", "cancel", or "next". You can also create custom follow-up intents.

When you create a follow-up intent, an output context is added to the parent intent and an input context of the same name is added to the child intent. This means that the follow-up intent is matched only when the parent intent is matched in the previous conversational turn.

To add a custom follow-up intent to the "Languages" intent:

  1. Select the "Languages" intent you created in previous steps.

  2. In the Response section, update the text response:

    • Wow! I didn't know you knew $language. How long have you known $language?
  3. Click Save.

  4. Click Intents in the left sidebar menu.

  5. Hover over the "Languages" intent and click Add follow-up intent.

  6. Click Custom in the revealed list.

Dialogflow automatically names the follow-up intent "Languages - custom".

Intent matching with follow-up intents

Follow-up intents are only matched after the parent intent has been matched. Since the "Languages - custom" intent is only matched after the "Languages" intent, you can assume that the user has just been asked the question "How long have you known $language?". Now you can add training phrases for likely user answers to that question.

  1. Click Intents in the left sidebar menu

  2. Click the "Languages - custom" intent.

  3. Add the following training phrases:

    • 3 years
    • about 4 days
    • for 5 years

Try it in the simulator

Enter I know French in the simulator, then answer the question "How long have you known French" with about 2 weeks.

Despite there being no response for the second query ("about 2 weeks"), we can see our query is matched to the correct intent ("Languages - custom"), and the duration parameter is correctly parsed ("2 weeks").

Intents and contexts

Inspect the "Languages" intent to see that "Languages-followup" is listed as an output context, prefaced by the number 2. This number is called the lifespan.

After the "Languages" intent is matched, the "Languages-followup" context is active and attached to the conversation for two turns (lifespan of 2). Therefore, when the user responds to the question, "How long have you known $language?", the "Languages-followup" context is active.

Inspect the "Languages - custom" intent to see that "Languages-followup" is listed as an input context, which is the same as the output context for the "Languages" intent.

Any intents with an input context that matches an active output context are heavily favored when Dialogflow matches intents.

Contexts and parameters

Contexts store parameter values, and you can access the values of parameters defined in the "Languages" intent when its output context is active.

In the "Languages - custom" intent, you only asked for the duration the user has known the language, and not the referenced language itself. Add the following response to the "Languages - custom" intent and click the Save button:

  • I can't believe you've known #languages-followup.language for $duration!

Try it in the simulator

Enter I know French in the simulator, and then respond to the question with 1 month. Notice that the language parameter value is retrieved from the context.

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Dialogflow Documentation
Trenger du hjelp? Gå til brukerstøttesiden vår.