NLU Certified Workshop

Topics:

Goals

It's time to build out your bot and customize it!

During our workshops, certain challenges come up over and over again. So, this section includes documentation and live walk-throughs from our Live workshops. 

The Goal of this section is to show you how to use these Dialogflow features through live examples. Please augment them per your needs. 

1. Setting up Google Assistant
Follow upI Intents & Slot Filling

Slot filling with required parameters

When building an agent, you can mark parameters as required. An intent is not complete until the end-user has supplied data for each of these required parameters.

 

When an intent is matched at runtime, the Dialogflow agent continues collecting information from the end-user until the end-user has provided data for each of the required parameters. This process is called slot filling.

Dialogflow does not send a fulfillment webhook request until it has collected all required data from the end-user, unless webhook for slot filling is enabled.

Dialogflow sends an API interaction response for each step of slot filling. For each of these slot filling responses, the intent and action will be the same, and the parameters collected so far will be provided.

When building an agent, you provide prompts that the agent will use to get parameter data from the end-user. You can also provide prompt variations, so the agent doesn't always ask the same question.

 

For example, consider that your clothing store agent has an intent with required parameters for:

  • clothing type

  • quantity

  • size

  • color

 

Completing an intent may look like the following:

User: I'd like to buy a t-shirt.
Agent: How many do you want?
User: 3
Agent: What color would you like?
User: Black
Agent: What size?
User: Medium
Agent: Got it, that was three black t-shirts in medium

If the end-user supplies data for more than one parameter in a single expression, Dialogflow collects the data provided and continues asking for the missing data. For example, the end-user may say "I'd like to buy three black t-shirts". Dialogflow would ask the user for the size.

Ordering parameters

When building an agent, you can order the parameters, which determines the order in which the agent will prompt the end-user for missing data.

When building an agent from the console, hovering over a parameter will reveal a reorder icon on the right. You can drag this icon to change the position of the parameter in the list.

Parameter references in prompts

When building an agent, you can use parameter references in prompts, but only for required parameters before the prompt. For example, if the color parameter is before the quantity parameter, you can use the following prompt for the quantity parameter: How many $color t-shirts would you like to buy?

Cancel slot filling

When the end-user says an exit phrase like "Cancel", "Stop it", "That's enough", etc., the agent replies with "Okay, canceled" and clears slot filling contexts.

2. Response Types

3. Knowledge Base

Add a document to the knowledge base

Your new knowledge base currently has no documents, so you should add a document to it. See Supported content below for a description of all supported content options. You can use the Cloud Storage FAQ document for this example.

Note: Knowledge documents are only parsed when explicitly creating or updating them. If your source content changes after creating a knowledge document, you need to update the knowledge document.

The samples below show you how to use the Dialogflow Console, REST API (including command line), or client libraries to create a knowledge document. To use the API, call the create method on the Document type.

Web UIREST & CMD LINEJavaNode.jsPython

Use the Dialogflow Console to create a knowledge document:

  1. If you are not continuing from steps above, navigate to your knowledge base settings:

    1. Go to the Dialogflow ES Console

    2. Select an agent

    3. Click Knowledge on the left sidebar menu

    4. Click your knowledge base name

  2. Click New Document or Create the first one

  3. Enter a document name

  4. Select text/html for Mime Type

  5. Select FAQ for Knowledge Type

  6. Select URL for Data Source

  7. Enter https://cloud.google.com/storage/docs/faq in the URL field

  8. Click CREATE

 

Creating a document is a long-running operation, so it may take a substantial amount of time to complete. You can poll the status of this operation to see if it has completed. Once completed, the operation contains the newly created document ID. Save this ID for future processing. For more information, see Long-running operations.

Manage knowledge documents

Update knowledge document content

If you update your content referenced by a knowledge document, your knowledge document is not automatically refreshed.

To refresh Cloud Storage or public URI document content, call the reload method on the Document type.

To refresh uploaded raw content, use the delete and create methods on the Document type to re-create your document.

List knowledge documents

You can list all knowledge documents for your knowledge base. To use the API, call the list method on the Document type.

Delete knowledge documents

You can delete knowledge documents for your knowledge base. To use the API, call the delete method on the Document type. If you do not have the document ID, you can list the documents as described above.

Supported content

The following knowledge document types are supported:

  • FAQ: The document content contains question and answer pairs as either HTML or CSV. Typical FAQ HTML formats are parsed accurately, but unusual formats may fail to be parsed. CSV must have questions in the first column and answers in the second, with no header. Because of this explicit format, they are always parsed accurately.

  • Extractive QA: Documents for which unstructured text is extracted and used for question answering.

The following table shows the supported MIME types by Knowledge Type and Source.

Turning Knowledge Bases Into Intents

4. Context & Follow-up Intents
Deep Dive

Input and output contexts

Input and output contexts are applied to intents. They work together to control conversation flow:

  • Output contexts control active contexts. When an intent is matched, any configured output contexts for that intent become active.

  • Input contexts control intent matching. While contexts are active, Dialogflow is more likely to match intents that are configured with input contexts that are a subset of currently active contexts.

 

With contexts, you can:

  • Control the order of intent matching.

  • Create context-specific intents with the same training phrases.

 

For example, consider the following intents:

Screen Shot 2022-01-13 at 7.14.56 PM.png

When the end-user says I like dogs:

  • The pet-select-dogs intent is matched.

  • The output context is dogs, so it becomes the active context.

 

When the end-user says I like cats:

  • The pet-select-cats intent is matched.

  • The output context is cats, so it becomes the active context.

 

When the end-user says What do they look like?:

  • If dogs is the active context:

    • The dog-show intent is matched.

    • The end-user is shown a dog picture.

  • If cats is the active context:

    • The cat-show intent is matched.

    • The end-user is shown a cat picture.

  • If there is no active context:

    • The pet-init intent is matched.

    • The end-user is asked what kind of pet they like.

 

Output contexts

Multiple output contexts can be applied to an intent. When an intent is matched, any output contexts applied to the intent become active.

 

Parameter references for active contexts

When an intent with output context is matched, its collected parameter values can serve as temporary storage with parameter references for active contexts. These values can be accessed during future intent matching, for as long as the context remains active.

For example, consider the following variation of the pet example above:

Screen Shot 2022-01-13 at 7.14.56 PM.png

When the end-user says I like dogs or I like cats:

  • The pet-select intent is matched.

  • The pet parameter is set to the chosen pet type.

  • The output context is pet-chosen, so it becomes the active context.

When the end-user says What do they look like?:

  • If pet-chosen is the active context:

    • The pet-show intent is matched.

    • If the end-user selected dogs in the prior conversational turn, the end-user is shown a dog picture.

    • If the end-user selected cats in the prior conversational turn, the end-user is shown a cat picture.

  • If there is no active context:

    • The pet-init intent is matched.

    • The end-user is asked to select a pet type.

Lifespan

Each active context has a lifespan that defines the number of conversational turns for which the context remains active. The default lifespan is five conversational turns for normal intents and two conversational turns for follow-up intents. You can override the default lifespan for any contexts. In addition, all contexts expire after 20 minutes of becoming active. When an intent is matched with an output context that is already active, the lifespan and expiration timer are reset.

For example, consider the following intent descriptions for a pet information agent:

Screen Shot 2022-01-13 at 7.26.22 PM.png

The following table shows an example dialogue for this pet information agent, which illustrates the lifespan of the pet-chosencontext:

Screen Shot 2022-01-13 at 7.26.31 PM.png

Input contexts

While contexts are active, Dialogflow is more likely to match intents that are configured with input contexts that correspond to the currently active contexts. The detailed intent matching rules are as follows:

  1. An intent's input context list must be a subset of the currently active context list in order to be matched. This also applies to intents with no input contexts.

  2. For intents that satisfy rule #1, those with an input context list that most closely match the currently active context list are more likely to be matched.

 

For example:

  • Intents with no input contexts can be matched at any time.

  • When no contexts are active, only intents with no input contexts can be matched.

  • If contexts "A" and "B" are active, an intent with "A" and "C" input contexts cannot be matched.

  • If contexts "A", "B", and "C" are active, an intent with "A" and "B" input contexts can be matched.

  • If contexts "A" and "B" are active, an intent with "A" and "B" input contexts is more likely to be matched than an intent with no input context or an intent with just "A" for an input context.

 

Follow-up intents

You can use follow-up intents to automatically set contexts for pairs of intents. A follow-up intent is a child of its associated parent intent. When you create a follow-up intent, an output context is automatically added to the parent intent and an input context of the same name is added to the follow-up intent. A follow-up intent is only matched when the parent intent is matched in the previous conversational turn. You can also create multiple levels of nested follow-up intents.

 

Dialogflow provides many predefined follow-up intents for common end-user replies like "yes", "no", or "cancel". You can also create your own follow-up intents to handle custom replies.

For example, a hair stylist agent might have the following nested intents.

Screen Shot 2022-01-13 at 7.40.29 PM.png

Where to find this data

When building an agent, it is most common to use the Dialogflow ES Console (visit documentationopen console). The instructions below focus on using the console. To access intent data:

  1. Go to the Dialogflow ES Console.

  2. Select an agent.

  3. Select Intents in the left sidebar menu.

If you are building an agent using the API instead of the console, see the Intents reference. The API field names are similar to the console field names.

Create a follow-up intent

To create a follow-up intent:

  1. From the intent list, hover your mouse pointer over the desired parent intent.

  2. Click Add follow-up intent.

  3. Select one of the predefined follow-up intents, or choose custom. The predefined follow-up intents already include training phrases for expected end-user replies.

Bonus: Troubleshooting
'Missing Owner Role' error.

 
 
 
 
 
gtag('config', 'AW-991893026')