
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create an Agent
/ 20
Importing a conversational agent file
/ 20
Testing your conversational agent
/ 20
Testing general FAQs vs context-sensitive FAQs
/ 20
Add flight upgrade to context-sensitive route group
/ 20
In the Dialogflow CX: Parameter Manipulation lab, you learned how to implement some advanced features of Conversational Agents in order to make your agent even more conversational. In this lab you'll learn how to use more of the advanced features of Conversational Agents to enhance the conversational experience of your conversational agent.
By the end of this lab, you will be able to:
last_page
that will be used to determine the flow of the conversation between Default Start Flow and the Upgrade flow.This lab builds upon the more advanced Flight Booker agent developed in Dialogflow CX: Parameter Manipulation and therefore assumes knowledge of Conversational Agents elements such as intents, entities, training phrases, flows, and pages. Building upon these basics, this lab will implement more advanced conversational techniques using some advanced features of Conversational Agents. Taking the earlier lab first is recommended, but you may proceed without it if you are already familiar with Conversational Agents and its fundamental features and usage.
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 Qwiklabs 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:
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab.
Note: If you are using a Pixelbook, open an Incognito window to run this lab.
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 a panel populated with the temporary credentials that you must use for this lab.
2. Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Open the tabs in separate windows, side-by-side.
If you see the Choose an account page, click Use Another Account.
3. In the Sign in page, paste the username that you copied from the Connection Details panel. Then copy and paste the password.
Important: You must use the credentials from the Connection Details panel. Do not use your Qwiklabs credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).
4. Click through the subsequent pages:
After a few moments, the Cloud Console opens in this tab.
In this task, you'll get logged into Conversational Agents and create a new agent.
Enable the Dialogflow API and Vertex AI Agent Builder API.
In your Google Cloud Console, navigate to Agent Builder > Conversational agent.
Click on Build your own when prompted to create an agent.
Name your agent Flight Booker - Contextual Intents .
Set the location to
Ensure timezone and default language are set appropriately. Set the Conversation Start to Flow.
Click on Create. Once the agent is created, you will see the design and configuration of the Conversational agent UI.
After creating the agent in the top-right side, navigate to Settings > General > Logging settings.
Click on Enable Cloud Logging option. It will generate logs for this agent.
Click on Save.
Click Check my progress to verify the objective.
In this task, you will import a Conversational agent from an earlier lab.
Select View all agents in the Agent dropdown menu at the top.
From the context menu (three vertical dots) to the right of your conversational agent, click on Restore.
Select the Cloud Storage radio button if not already selected.
Enter the following for the URI:
Click Restore.
Refer to the Conversational Agents "restore" documentation as needed.
Now you have a conversational agent that has everything completed from the earlier lab.
If you'd like to retain a copy of the sample agent, click to download gsp986-start-agent.blob to your local hard drive.
Click Check my progress to verify the objective.
For this lab, you will notice an Upgrade flow has been added in addition to the output from the earlier lab. The purpose is to allow you to jump ahead to implement some more advanced features during the time allotted for the lab.
Confirm the following pages and intents appear in your conversational agent:
Pages:
Flows:
Intents:
In conversations, sometimes you ask the other person to repeat what they just said. In the same way, you would like to have this capability for your conversational agent. This scenario is more likely to happen with a voice-enable conversational agent than in a chat bot. For a lab that addresses this interactive voice recognition (IVR) setup, please see the Dialogflow CX: Enable IVR Features for your Voice Agent lab.
Navigate to Conversational Agents > Manage > Intents and add a new user.request.repeat intent with the following configuration:
Config item | Value |
---|---|
New intent name | user.request.repeat |
Sample training phrases | 'say again', 'repeat', 'please repeat that', and 'can you say that again?' |
Next, you'll add the repeat option to selected parts of the conversation including the flight status and booking scenarios.
Navigate to Conversational Agents > Build > Default Start Flow and click on the Confirm flight status flow. Click on + beside Routes and add a new user.request.repeat route with the following configuration:
Config item | Value |
---|---|
Page | Confirm flight status |
Add Route, Intent name | user.request.repeat |
Fulfillment, i.e., Agent says | 'Sure, let me repeat that:' |
Transition page | Check flight status |
Test the functionality you added to repeat the data the user requested. For instance, try testing with the following:
Who | Message |
---|---|
User | I want to check flight status |
Agent | What is your flight booking reference please? |
User | ND48PQ |
Agent | Looking up your flight reference ND48PQ, ... |
User | Please repeat |
Agent | Sure, let me repeat that: Looking up your flight reference ND48PQ, ... |
Click Check my progress to verify the objective.
Knowledge check
Frequently Asked Questions (FAQs) may happen at any stage of a conversation. For instance, FAQs include questions about store opening hours, refund policies, etc. In an airline scenario, some FAQs are about carry-on baggage limits and flight upgrades.
In this section, you will create a few FAQs and explore the use of route groups to group these FAQs. This will enable your conversational agent to deviate from a conversational flow, quickly answer these side queries, and then return to the main flow of the conversation.
Intent>> | faq.miles.upgrade | faq.cabin.limits | faq.cabin.batteries |
---|---|---|---|
Phrase 1 | Can I upgrade to 1st class using my frequent flyer miles? | How many bags can I bring into the cabin with me? | What about Power Banks? |
Phrase 2 | First class upgrade with miles | What is the limit on carry-on baggage? | Can I bring portable batteries on board? |
Phrase 3 | Business class upgrade with miles | Can I bring more than 2 bags into the cabin? | Is there a limit on the power bank I can bring into the cabin? |
Phrase 4 | Request upgrade | Am I limited to two? | Power bank |
Phrase 5 | I want an upgrade | What's the max on bags? | Lithium batteries |
Select Route Groups under the Manage tab.
Click + Create.
For level select Flow and for flow select Default Start Flow.
Enter General FAQs for the Display name.
Click on Save.
Click into the newly created General FAQs route group.
Next, you'll add all three of the FAQ intents you created.
For each intent in the list, click Add route, select the intent, and add the following for the fulfillment messages and click Save:
Intent | Message |
---|---|
faq.miles.upgrade | Yes, depending on the flight and availability, we can put in a request for an upgrade from Economy. |
faq.cabin.limits | It depends on the destination airport. Generally, you are allowed a maximum of 1 cabin bag, not exceeding 7kg and with the Sum of L + W + H (including the wheels) must be no more than 115cm (45 inches). |
faq.cabin.batteries | For Lithium batteries (includes Power Banks), no more than two spare batteries exceeding 100Wh and up to 160Wh, are permitted. |
Next, you need to add the route group to the Start page in the Default Start Flow so that Conversational Agent knows you want the intents/routes defined in the route group triggered any time it finds a match during the flow.
Go to the Build tab.
Click on Start Page.
Click Add state handler.
Click on the checkbox to enable Route groups then click on Apply.
Click + to the right of Route groups to add a new route group.
Select General FAQs from the route group dropdown.
Click on Save.
Notice the General FAQs route group shows (3)
next to it indicating that it contains three routes.
For testing purposes, use the following as a guide to explore each turn of the conversation where an FAQ pops up.
Who | Message |
---|---|
User | How many bags can I bring into the cabin? |
Agent | It depends on the destination airport. Generally, you are allowed ... |
User | Book a flight |
Agent | What city would you like the flight to depart from? |
User | Sydney |
Agent | What is the month and day of the departure? |
User | What about Power Banks? |
Agent | For Lithium batteries (includes Power Banks), ... What is the month and day of the departure? |
User | Tomorrow |
Agent | What is your destination city? |
User | Can I get an upgrade? |
Agent | Yes, depending on the flight and availability, ... What is your destination city? |
Feel free to test additional scenarios to be satisfied that General FAQs will work from any page now that you have the General FAQs route group in the Start page of the Default Start Flow.
Knowledge check
Click Check my progress to verify the objective.
Depending on the stage of a conversation, a question may result in a general answer or a more specific answer. Context is key. For instance, if you enquire about upgrading your flight with your frequent flyer points, the answer could be general in the sense that you can upgrade the flight based on points and seat availability. If you have a booked flight, asking the same question would result in a more specific answer because you would know the points required and if there are seats available.
In this section, you will use the same route group feature to create a context-sensitive route group.
Repeat the steps to create a new route group, this time calling it FAQs during Flight Status.
Add only one FAQ intent, faq.cabin.limits, to this route group for now.
Enter a fulfillment message for faq.cabin.limits such as:
Set the transition target for faq.cabin.limits route to the Check flight status page.
Click on Save.
Navigate to the Confirm flight status page.
Click Add state handler.
Click on the checkbox to enable Route groups and then click on Apply.
Click + to the right of Route groups to add a new route group.
Add the new FAQs during Flight Status route group.
Click on Save.
Click on the FAQs during Flight Status route group.
Your configuration should look like the following:
For testing purposes, use the following as a guide to explore each turn of the conversation.
Who | Message |
---|---|
User | Cabin bags as carry-on? |
Agent | It depends on the destination airport. Generally, you are allowed ... |
User | Check flight status |
Agent | What is your flight booking reference please? |
User | PNR235 |
Agent | Looking up your flight reference PNR235, ... |
User | Cabin bags limit? |
Agent | For this flight: You are only allowed a small cabin bag not exceeding ... |
Now you'll add another route to the FAQs during Flight Status route group. This time the route will call another flow that will be reused in the "Flight Booking" conversational flow later.
Navigate back to the Confirm flight status page as needed.
Select the FAQs during Flight Status route group.
Click Add route.
Select the faq.miles.upgrade intent.
Select the Flow radio button in the Transition section.
Select the Upgrade flow.
Click Save.
Now you will test the new upgrade scenario.
Test with the following:
Who | Message |
---|---|
User | Check flight |
Agent | What is your flight booking reference please? |
User | PNR987 |
Agent | Looking up your flight reference PNR987, ... |
User | I want an upgrade |
Agent | What is your frequent flyer number please? |
User | 098765 |
Agent | Thank you. Confirming request for upgrade has been received... |
User | Ok, Great. |
Agent | Can you say that again? |
Notice the page and parameter information in the simulator. You can see that you are still in the upgrade flow and in the Upgrade request received page. It appears the upgrade flow did not return to the Confirm flight status page from the Default Start Flow.
Click Check my progress to verify the objective.
One way to fix this is to change the Upgrade request received page in the upgrade flow to end the flow so that control can be returned to the calling Confirm flight status page.
Navigate to the Upgrade request received page in the Upgrade flow.
Open the configuration pane of the only route there. It has a label, true
and it's a condition type of route. Note that you may have to click on Routes first.
true
is a reserved word which Conversational agents treats as an expression evaluated to true. When a route condition is configured this way, Conversational agents will always take the route, that is except if there is another route in the list before it that takes precedence over it.
Scroll down to the Transition section.
Change the transition page, selecting End Flow from the flow drop-down.
Click Save.
Repeat the test with the following:
Who | Message |
---|---|
User | Check flight |
Agent | What is your flight booking reference please? |
User | PNR888 |
Agent | Looking up your flight reference PNR888, ... |
User | upgrade |
Agent | What is your frequent flyer number please? |
User | 12341324 |
Agent | Thank you. Confirming request for upgrade has been received... |
User | Great! |
Agent | Sorry, could you say that again? |
User | Yes, please go ahead. |
Agent | Our agents will be in touch soon for your request ... |
Review the data in the test simulator and note the agent has successfully transferred control from the upgrade flow back to the Confirm flight status page in the Default Start Flow and finally the Anything else? page. That's good.
But wait! For the routes of the Confirm flight status page, you are only expecting three possible intent responses: confirmation.yes
, confirmation.no
, and user.request.repeat
. This is precisely why the conversational agent does not understand the "Great" response from the end user.
One way to fix this is to change the behavior of the upgrade flow and also make it more reusable for other parts of the Default Start Flow. You'll use a custom session parameter to achieve this slightly more sophisticated routing next.
In this section you'll introduce a new session parameter named last_page
and see how this will help route between Default Start Flow and the Upgrade flow more seamlessly.
Navigate back into the FAQs during Flight Status route group. You can get to it either from the Confirm flight status page or from Route Groups under the Manage tab.
Click to edit the faq.miles.upgrade route.
Scroll down to the Parameter presets section.
Click Add a parameter.
Add "last_page" as the parameter name and set the value to "Flight Status"
. Note that the value needs to be in double quotes.
Click Save.
Navigate to the Upgrade flow.
Click on the Upgrade request received page.
Click on the only route there (with label true
).
Change the route transition from End Flow to Default Start Flow. (Hint: make sure the Flow radio button is selected.)
Click Save.
Navigate back to Default Start Flow.
Click on the Start page.
Click + to add a new route.
Scroll to the Condition section.
Select the default, Match AT LEAST ONE rule (OR).
Enter $session.params.last_page
in the parameter field.
Ensure the operator is set to =
(it should be by default).
Enter "Flight Status"
in the value field. Note that quotes are required in this case because there are two words.
Choose the Check flight status page in the Transition section.
Click Save.
Up to now, the Start page in the Default Start Flow had only intent routes. Now your Start page has a new route that is based on a condition rather than an intent.
Add the last_page
parameter to the parameter presets of your Anything else? page so that it's set to null again as appropriate, like the other parameters.
Test with the following:
Who | Message |
---|---|
User | Check flight |
Agent | What is your flight booking reference please? |
User | By the way, can I get an upgrade? |
Agent | Yes, depending on the flight and availability, ... |
User | PNR888 |
Agent | Looking up your flight reference PNR888, ... |
User | I would like to upgrade my flight |
Agent | What is your frequent flyer number please? |
User | 1234321 |
Agent | Thank you. Confirming request for upgrade has been received... |
last_page
parameter is set to "Flight Status" when the faq.miles.upgrade
route (in the 'FAQs during Flight Status' route group) is triggered. The Upgrade flow is called, which is where the frequent flyer number is requested, and the upgrade request is confirmed.
The Upgrade flow exits by transitioning to the Start page of the Default Start Flow. The route in the Start page detects the last_page
parameter is set to "Flight Status" and routes this automatically to the Check flight status page.
In the Check flight status page, the required PNR number parameter is already filled and thus it transits automatically back to Confirm flight status, and the loop is complete.
Can you reuse this flow during flight booking? Certainly!
For instance, if you were branching from the flight booking part of the conversational flow, specifically at the Confirm trip page, you can assign a booking value to the last_page
parameter. That way users can request an upgrade after booking a flight and experience the same flow.
last_page
condition routing for the flight booking part of the conversation.For instance, in the booking scenario, the condition would be when last_page
= "Booking" and the transition would be to the Ticket information page. Don't forget to create a new route group for 'FAQs during Booking' to handle the new routes and add it to the confirmation stage of your flow.
Knowledge check
If you want to export your conversational agent to use in your own project, use the following steps:
Select View all agents from the Agent dropdown at the top.
Click on the context menu (three vertical dots) and choose Export.
Click on the Download button under Export agent to.
Click Export.
You now know how to add a Repeat intent and route for it, create FAQ intents that can be used to match user's general questions to the generic answers, create route groups to handle contextual questions (FAQs asked in the middle of another part of the conversation), and create a session parameter to determine the flow of the conversation between flows.
This self-paced lab is part of the Create Conversational AI Agents with Dialogflow CX quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Refer to the Google Cloud Skills Boost catalog for all available quests.
...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 December 27, 2024
Lab Last Tested December 27, 2024
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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one