Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Labs

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.

Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Jan 27, 2023

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Enable APIs

    1. Enable DialogFlow API.
    2. Enable Cloud Functions API.
    3. Enable Cloud Build API.
  2. Challenge

    Retrieve Working Files

    1. Activate Cloud Shell.
    2. Retrieve the working files:
    git clone https://github.com/linuxacademy/content-google-cloud-certified-professional-machine-learning-engineer
    
    1. Change to the establish-dialogflow-webhook directory.
    2. Download the exported Dialogflow agent:
    cloudshell download exported_agent_acg-apparel.blob
    
  3. Challenge

    Import the Dialogflow Agent

    1. Go to the Dialogflow CX console at https://dialogflow.cloud.google.com/cx/projects.
    2. Select the project starting with establishing….
    3. Create Agent with the following parameters:
    • Name: ACG Apparel
    • Region: us-east1
    1. Restore the previously downloaded agent.
  4. Challenge

    Create the Cloud Function

    1. Navigate to Cloud Functions.
    2. 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
    1. Select Go 1.16 for the Runtime.
    2. Copy the contents of the function.go file and paste to the function.go field.
    3. Name the entry point HandleWebhookRequest.
    4. Deploy.

    Note: This process can take up to two minutes to complete.

  5. Challenge

    Insert the Webhook

    1. Switch to the Dialogflow CX Console.
    2. 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
    1. Apply the webhook.
    2. Delete the existing text response under the Agent says heading. When you hover the text, the delete button appears.
    3. Enable webhook.
    4. Use the hoodie-agent-webhook.
    5. Set up the parameter.
    6. 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!.
  6. Challenge

    Test the Webhook

    1. Test agent by using the following responses:
    Hello
    I would like to buy a hoodie
    Green please
    Large I think
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans