Dialogflow Logging and Monitoring in Operations Suite

Join Sign in

Dialogflow Logging and Monitoring in Operations Suite

1 hour 30 minutes 5 Credits


Google Cloud self-paced labs logo


In this lab you will continue working on the Pigeon Travel virtual agent created in the Adding a Phone Gateway to a Virtual Agent lab. Now you will learn how to use Google Cloud tools to troubleshoot and debug your virtual agent.

Important: You will need the exported agent zip file from the Design Conversational Flows for your Agent lab to continue with this lab. If you don't have these files, you can download the example files provided in the lab

Contact Center AI is designed to easily integrate into existing telephony technology. In order to create a phone gateway, you need to have access to a telephony partner, and this lab will give you that access. For production usage, work with one of these partners.

What you'll learn

In this lab you will perform the following tasks:

  • Use Dialogflow tools for troubleshooting.

  • Use Google Cloud tools for debugging your virtual agent.

  • Review logs generated by your virtual agent activity.

  • Design Conversations using best practices.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Enable the API

  1. In the Cloud Console go to Navigation menu > APIs & Services > Enable APIs and Services.

  2. Click on +Enable APIs and Services.

  3. Search for Dialogflow.

  4. Click on the Dialogflow API and if the API is not Enabled, click Enable.

Task 1. Create your Dialogflow agent

You'll call your agent "pigeon-travel".

  1. Go to the Dialogflow Console.

  2. Sign in with the Google button, and make sure to select the lab credentials you logged into this lab with. Then click Allow.

  3. Accept the Terms of Service.

  4. Click Create new agent.

  5. Now add the agent information as you see below:

    • Agent Name: pigeon-travel
    • Default Time Zone: America/Denver
    • Google Project: use your Qwiklabs Project ID
  6. Click Create.

Click Check my progress to verify the objective. Create a Dialogflow agent

Task 2. Import your Dialogflow agent

In the previous lab, you exported the Dialogflow agent you built. You will now import it back in and continue building it.

If you do not have exported files to use, use this file.

Download the file to your local workstation.

This will create a new virtual agent project. Now you'll want to import the work you've already done.

  1. Click on the settings gear icon in line with your agent name.

  2. Select the Export and Import tab.

Export and Import tab


  2. Click SELECT FILE and navigate to the zip file which contains the configuration of your virtual agent. You can alternatively drag and drop the file if you prefer.

  3. Type in the word "IMPORT" in all caps to enable the import button and click IMPORT.

Upload agent section

  1. Click DONE to close out the upload window once the import is complete.

Your existing configuration has been imported into your new agent project.

Click Check my progress to verify the objective. Import the Dialogflow agent

Task 3. Set up a phone gateway

To set up your gateway, follow these steps:

  1. Select a provider. From the Dialogflow Console:

    • Select your agent, pigeon-travel.
    • Click Integrations.
    • Click Dialogflow Phone Gateway.
  2. Configure Phone Gateway:

    • Select the language - for this lab choose English.
    • Select the country code for the telephone number - for this lab select +1 for the United States.
    • Click Next.
  3. Select a number:

    • Choose a telephone number from the list.
    • Click Create.
  4. Completion:

    • The gateway is now active.
    • Save the displayed telephone number and close the dialog window. You can click the Dialogflow Phone Gateway integrations button again to retrieve this information.

Click Check my progress to verify the objective. Set up a phone gateway

Task 4. Set up fulfillment using Cloud Functions to look up reservations in Firestore

In this section, you will set up Firestore for your agent to look up the current reservation and add the change.

Configure Firestore

  1. In the Cloud Console go to Navigation menu > Databases > Firestore.

  2. You will be presented with two options, Native Mode or Datastore Mode. Choose SELECT NATIVE MODE.

  3. For the location choose nam5 (United States).

  4. Click CREATE DATABASE. Once it completes you will have the ability to create a new collection.


  6. Fill in the details to replicate the details below, then click SAVE.

    • Collection ID: reservations

    • Document ID: 100

    • Field name: fname

    • Field type: string

    • Field value: Isabel

    Then click the + button to add another:

    • Field name: lname
    • Field type: string
    • Field value: Costa

    Then click the + button to add another:

    • Field name: newname
    • Field type: string
    • Field value: Leave it blank

Start a collection page

You have now added your first document to a Firestore collection.

Firestore Document IDs Best Practice

  • Avoid the document IDs

  • Avoid using / forward slashes in document IDs

  • Do not use monotonically increasing document IDs such as:

    • Customer1, Customer2, Customer3, ...
    • Product 1, Product 2, Product 3, ...

    Such sequential IDs can lead to hotspots that impact latency.

Dialogflow fulfillment

  1. Click on Fulfillment in the left menu. It may take a few minutes for the resources to be provisioned.

  2. Inline with the Inline Editor option, slide the slider to the right so it appears ENABLED. This enables the Cloud Functions editor within your Dialogflow agent.

Note: If you receive an error message, try refreshing the page and then try enabling the Inline Editor again.
  1. Click on the Deploy button on the bottom right. This may take a few minutes.

  2. Once deployment is successful, in the Cloud Console, from the Navigation menu navigate into Cloud Functions and confirm the function has been deployed (look for the name you noticed in Step 4).

  3. In the previous lab you downloaded the Cloud Function source code. You will now upload this code to the newly deployed Cloud Function.

    If you do not have exported files to use, download this file to your local workstation:

  4. In the Cloud Console, locate the newly deployed function and click on the function name to open it.

  5. Click EDIT.

  6. Click Next and set Source code to ZIP upload.

  7. Browse for the ZIP (Cloud Function source code) you downloaded in the previous lab.

  8. Choose a Stage Bucket. If no buckets are listed, go ahead and create one.

Cloud Functions section

  1. Click DEPLOY

Once it completes, you have the code from the previous lab deployed to your fulfillment Cloud Function.

Click Check my progress to verify the objective. Set up fulfillment using Cloud Functions

Task 5. Dialogflow tools for troubleshooting

You have a few tools at your disposal for troubleshooting and debugging.

  • Dialogflow History

  • Cloud Logging

What is Dialogflow History?

The History page shows a simplified version of the conversations your agent has engaged in. These logs are chronological and intended to be an overview of how users interact with your agent.

How to use Dialogflow History

  • Fix unmatched intents

  • View interaction logs

  • View conversations

  • See webhook errors in Operations logs

Task 6. Fix unmatched intents

Interactions that had issues with intent matching will have a warning icon in yellow, while interactions that had webhook errors will have a warning icon in red.

Warning message

  1. Click History in the Dialogflow Console Menu.

  2. When you click the Option icon for the listed interaction, you'll see options for troubleshooting:

    • Go to intent - This will take you directly to the intent that was matched. If no intent was matched, this option will not be available.
    • From there, you can add the training phrase to the intent to ensure it will be matched in the future.
Note: You will use the Dialogflow Simulator to add interactions to your history.
  1. In the Dialogflow Simulator, type in the following:

I need to update my last name

  1. This should fallback to the Default Fallback Intent.

  2. Click History in the Dialogflow Console Menu.

  3. Locate the phrase you entered above and click on it. It will expand and display the warning.

Expanded warning

The AGENT was not able to find a matching intent. Fix this by adding a phrase to the intent.

  1. Click on Intents.

  2. Click the name.reservation intent.

  3. Go to Training Phrases and enter the following: I need to update my last name

  4. Click Save.

  5. Try the phrase again in the Dialogflow Simulator.

  6. You should now see the intent matched.

Default response

Task 7. Webhook errors in logging

To view logs, you must enable them in the agent.

  1. On the Setting icon > General tab, scroll down to the LOG SETTINGS section and enable the Log Interactions to Google Cloud.

  2. Click on the Open logs link.

  3. Click Save.

Log Settings section

When an error occurs with a webhook, the interaction will have a red warning error icon. You can hover over the icon to see a brief description of what happened.

To view the specific block of logs pertaining to the interaction, click on the option icon and then click View logs in Operations.

Operation log view

  1. Go to Cloud Console and click on Cloud Functions.

  2. Click the Dialogflow Function.

  3. Click on the EDIT, then click Next.

  4. Edit the INDEX.JS as follows:

    Comment out this line of code, it is towards the bottom:

    intentMap.set('name.reservation-getname', reservation);

    Change it to:

    // intentMap.set('name.reservation-getname', reservation);

    Comment code

  5. Click DEPLOY.

  6. In the Dialogflow Simulator, start a conversation by typing:

    I need to update my last name

  7. Go to History in the Dialogflow Console.

  8. Locate the Conversation you started and click on it to expand the details.

  9. You will notice the last interaction with the AGENT is blank:

Conversation blank

  1. In the options menu click View logs in Operations.

  2. Notice the error Dialogflow fulfillment error : Webhook call failed. Error: UNAVAILABLE, State: URL_UNREACHABLE, Reason: UNREACHABLE_5xx, HTTP Status code: 500.

You are missing some information that can help troubleshoot the message.

  1. Click Clear query to clear the Query field, and then click Run Query.

Towards the bottom you will now see Error: No handler for requested intent, which is related to the intent map you commented out above.

 Error: No handler for requested intent

If you do not see the error message, make sure you choose the correct resource. You can change the Resource to the Cloud Function > dialogflowFirebaseFulfillment.

Task 8. Best Practices

Training phases

  • Ensure there are adequate training phases in place. At least 10 training phases for each of the intents is recommended.

  • Each of the training phases should contain different types of expressions that would trigger the intent.

  • Training phases should also contain similar meaning wording.

Intent priority

Multiple intents are similar to each other. You can set a priority for each intent. If an end-user expression matches multiple intents, Dialogflow will match it to the intent with the highest priority

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. A negative priority value corresponds to the Ignore priority in the console and is used to disable the intent for runtime detect intent requests.

If the intent contains a training phase that is an “exact” match with user input, despite the configuration of the Priority and the Input Context, the intent that contains the “exact” match of the user input will be triggered during the intent race. As “exact” match within the intent indicates the exact intent and context of the user want, which will be treated as the highest priority.

  1. Click Intents from the left menu.

  2. Click on name.reservation Intent.

  3. In the upper left corner you will notice a blue dot, click on the blue dot to change the intent priority.

Intent priority menu

Entity terminology

The term "entity" is used in the Dialogflow Console to describe the general concept of entities.

  • Entity type defines the type of information you want to extract from user input. For example, "vegetable" could be the name of an entity type.

  • Entity entry for each entity type, there are many entity entries. Each entity entry provides a set of words or phrases that are considered equivalent. For example, if vegetable is an entity type, you could define these three entity entries:

    • Carrot
    • Scallion, green onion
    • Bell pepper, sweet pepper
  • Custom entity names are unique for each agent. Entity names should start with a letter and can contain the following: A-Z, a-z, 0-9, _ (underscore), - (dash) .

  • Make sure that the entity with the same entity entry is used in a “non-competing” intent. Intents should have very distinct training phrases, or they need to be restricted by different input contexts.

To create a custom map entity:

  1. Click Entities from the left menu.
  2. Click Create entity.
  3. Enter a name for the entity shirt-size
  4. Note that Define synonyms is already checked.
  5. Click the first row and provide a reference value in the left column.
  6. Click the next column or press Enter and provide synonyms.
  7. Continue adding rows for other entity entries.
  8. Click Save.

shirt-size entity

  1. Create a get-shirt-size intent:

  2. Click on the next to Intents in the left menu.

  3. Add the name "get-shirt-size" into the Intent name text field.

  4. In the Training Phrases section, click on Add Training Phrases and enter the following, pressing Enter after each entry:

  • XL

  • XS

  • M

  • L

  • S

  • XXL

  1. In the Text Response type in the following:

Thank you, I will ship out a $shirt-size shirt to the address we have on file, thank you.

  1. Click Save.

Click Check my progress to verify the objective. Create an entity and an intent

  1. Go to Cloud Console and click on Cloud Functions.

  2. Select the Dialogflow Function.

  3. Click on the EDIT button.

  4. Edit the INDEX.JS as follows:

  • Uncomment the line of code:

intentMap.set('name.reservation-getname', reservation);

  • On or about line 35, change:

agent.add('Ok. I have updated the name on the reservation');


agent.add('Ok. I have updated the name on the reservation. I want send you a free T-Shirt as thank you. What shirt size are you?');

  1. Click Deploy.

  2. Once the Cloud Function is deployed, test with the Dialogflow Simulator. Type in the following:

  • I need to update my last name
  • Isabel
  • 100
  • Isabella
  • XL

If it does not work the first time, try again as the function might still be updating.

Agent validation

To help agent designers create high-quality agents, Dialogflow provides a validation feature. Agent validation results are available automatically whenever agent training is performed and completed. You can access the results of validation from either the Dialogflow Console or the API.

The validation results provide a list of errors that you should correct to improve the quality and performance of your agent. If your agent has errors, you can choose to ignore them and launch your agent. Here are some examples that you might find:

  • Intent has training phrases which are too similar.
  • Intent contains a parameter that is not used in enough training phrases.
  • There are no negative examples for the fallback intent.
  • This text is annotated in some training phrases but not others.

Enable and disable automatic validation

By default, agent validation is automatically performed whenever the agent is trained. You can enable and disable this setting in the Dialogflow Console:

  • Select your agent.
  • Click the settings icon next to the agent name.
  • Select the ML Settings tab.
  • Toggle the Agent Validation setting on (default) or off.

To access the validation data for your agent:

  • Go to the Dialogflow Console.
  • Select your agent.
  • Click Validation in the sidebar menu.

When you visit either the intents list or the entities list pages, any intents or entities with validation errors show an error indicator next to the name.

When you visit a page for a specific intent or entity that has validation errors, an error error_outline indicator is shown near the Save button.

Clicking this button shows a list of errors for the intent or entity. By default, only errors with a severity of CRITICAL or ERROR are shown. You can toggle the types of severities to also show WARNING and INFO.


You have learned how to use Google Cloud tools to troubleshoot and debug your virtual agent.

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated February 23, 2023

Manual Last Tested February 23, 2023

Copyright 2023 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.