- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- AI
- Cloud

Establishing a Dialogflow Webhook
Google Cloud Dialogflow creates virtual agents capable of conversing with people to convey and receive information in context. While the Dialogflow UI is quite robust, there are situations that require calculations which can be supplied by a Google Cloud Function when called by a webhook. In this Hands-On Lab, you'll import a Dialogflow CX agent and then modify it to replace a static response with one programmatically output by a Cloud Function and integrated by a webhook.

Lab Info
Table of Contents
-
Challenge
Enable APIs
- Enable DialogFlow API.
- Enable Cloud Functions API.
- Enable Cloud Build API.
-
Challenge
Retrieve Working Files
- Activate Cloud Shell.
- Retrieve the working files:
git clone https://github.com/linuxacademy/content-google-cloud-certified-professional-machine-learning-engineer
- Change to the
establish-dialogflow-webhook
directory. - Download the exported Dialogflow agent:
cloudshell download exported_agent_acg-apparel.blob
-
Challenge
Import the Dialogflow Agent
- Go to the Dialogflow CX console at https://dialogflow.cloud.google.com/cx/projects.
- Select the project starting with
establishing…
. - Create Agent with the following parameters:
- Name: ACG Apparel
- Region:
us-east1
- Restore the previously downloaded agent.
-
Challenge
Create the Cloud Function
- Navigate to Cloud Functions.
- Apply the following parameters:
- Function name: hoodie-dialogflow-webhook
- Region:
us-east1
- Trigger type:
HTTP
- URL: Copy and save the value. (You will need this URL when configuring the webhook.)
- Authentication:
Require authentication
- Require HTTPS
- In the Runtime, build, connections and security settings section, go under RUNTIME and set the Maximum number of instances to 1.
- Select Go 1.16 for the Runtime.
- Copy the contents of the
function.go
file and paste to thefunction.go
field. - Name the entry point HandleWebhookRequest.
- Deploy.
Note: This process can take up to two minutes to complete.
-
Challenge
Insert the Webhook
- Switch to the Dialogflow CX Console.
- Create the webhook with the following details:
- Display name: hoodie-agent-webhook
- Webhook URL: Paste the previously copied webhook URL
- All other fields use default values
- Apply the webhook.
- Delete the existing text response under the Agent says heading. When you hover the text, the delete button appears.
- Enable webhook.
- Use the
hoodie-agent-webhook
. - Set up the parameter.
- Add the following text response in the Agent Says field, You can cancel your order within $session.params.cancel-period business days. Thanks for your order. Have a great day!.
-
Challenge
Test the Webhook
- Test agent by using the following responses:
Hello I would like to buy a hoodie Green please Large I think
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.