Checkpoints
Create a Dialogflow agent
/ 20
Import your Dialogflow agent
/ 20
Set up a phone gateway
/ 20
Set up fulfillment using Cloud Functions
/ 20
Create an entity and an intent
/ 20
Dialogflow Logging and Monitoring in Operations Suite
GSP794
Overview
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.
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).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud Console
-
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
-
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. -
If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.
-
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. -
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.
Enable the API
-
In the Cloud Console go to Navigation menu > APIs & Services > Enable APIs and Services.
-
Click on +Enable APIs and Services.
-
Search for Dialogflow.
-
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".
-
Go to the Dialogflow Console.
-
Sign in with the Google button, and make sure to select the lab credentials you logged into this lab with. Then click Allow.
-
Accept the Terms of Service.
-
Click Create new agent.
-
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
- Agent Name:
-
Click Create.
Click Check my progress to verify the objective.
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.
-
Click on the settings gear icon in line with your agent name.
-
Select the Export and Import tab.
-
Click IMPORT FROM ZIP.
-
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.
-
Type in the word "IMPORT" in all caps to enable the import button and click IMPORT.
- 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.
Task 3. Set up a phone gateway
To set up your gateway, follow these steps:
-
Select a provider. From the Dialogflow Console:
- Select your agent,
pigeon-travel
. - Click Integrations.
- Click Dialogflow Phone Gateway.
- Select your agent,
-
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.
-
Select a number:
- Choose a telephone number from the list.
- Click Create.
-
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.
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
-
In the Cloud Console go to Navigation menu > Databases > Firestore.
-
You will be presented with two options, Native Mode or Datastore Mode. Choose SELECT NATIVE MODE.
-
For the location choose nam5 (United States).
-
Click CREATE DATABASE. Once it completes you will have the ability to create a new collection.
-
Click START COLLECTION.
-
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
-
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
-
Click on Fulfillment in the left menu. It may take a few minutes for the resources to be provisioned.
-
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.
-
Click on the Deploy button on the bottom right. This may take a few minutes.
-
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).
-
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:
-
In the Cloud Console, locate the newly deployed function and click on the function name to open it.
-
Click EDIT.
-
Click Next and set Source code to ZIP upload.
-
Browse for the ZIP (Cloud Function source code) you downloaded in the previous lab.
-
Choose a Stage Bucket. If no buckets are listed, go ahead and create one.
- 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.
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.
-
Click History in the Dialogflow Console Menu.
-
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.
- In the Dialogflow Simulator, type in the following:
I need to update my last name
-
This should fallback to the Default Fallback Intent.
-
Click History in the Dialogflow Console Menu.
-
Locate the phrase you entered above and click on it. It will expand and display the warning.
The AGENT was not able to find a matching intent. Fix this by adding a phrase to the intent.
-
Click on Intents.
-
Click the name.reservation intent.
-
Go to Training Phrases and enter the following:
I need to update my last name
-
Click Save.
-
Try the phrase again in the Dialogflow Simulator.
-
You should now see the intent matched.
Task 7. Webhook errors in logging
To view logs, you must enable them in the agent.
-
On the Setting icon > General tab, scroll down to the LOG SETTINGS section and enable the Log Interactions to Google Cloud.
-
Click on the Open logs link.
-
Click Save.
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.
-
Go to Cloud Console and click on Cloud Functions.
-
Click the Dialogflow Function.
-
Click on the EDIT, then click Next.
-
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);
-
Click DEPLOY.
-
In the Dialogflow Simulator, start a conversation by typing:
I need to update my last name
-
Go to History in the Dialogflow Console.
-
Locate the Conversation you started and click on it to expand the details.
-
You will notice the last interaction with the AGENT is blank:
-
In the options menu click View logs in Operations.
-
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.
- 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.
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.
-
Click Intents from the left menu.
-
Click on
name.reservation
Intent. -
In the upper left corner you will notice a blue dot, click on the blue dot to change the intent priority.
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:
- Click Entities from the left menu.
- Click Create entity.
- Enter a name for the entity
shirt-size
- Note that Define synonyms is already checked.
- Click the first row and provide a reference value in the left column.
- Click the next column or press Enter and provide synonyms.
- Continue adding rows for other entity entries.
- Click Save.
-
Create a
get-shirt-size
intent: -
Click on the ➕ next to Intents in the left menu.
-
Add the name "get-shirt-size" into the Intent name text field.
-
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
- 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.
- Click Save.
Click Check my progress to verify the objective.
-
Go to Cloud Console and click on Cloud Functions.
-
Select the Dialogflow Function.
-
Click on the EDIT button.
-
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');
to:
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?');
-
Click Deploy.
-
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.
Congratulations!
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.