aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
code
  • Engineering
  • Programming
  • Software Engineering

Using A Subflow In Dialogflow CX

  • aster_cloud
  • January 13, 2022
  • 4 minute read

One of the best practices of software development is to refactor common code into modules and then use it across your application. A key feature of Dialogflow CX is to ensure that multiple teams are able to work on complex agents. This will require that it supports reuse of common functionality across flows, not just in a single agent but even across agents.

In this blog post, we are going to take a look at how to use a Subflow while designing a Dialogflow CX Agent. Think of a subflow as some common functionality that you would like to utilize in one or more flows.


Partner with aster.cloud
for your next big idea.
Let us know here.


cyberpogo

Sample Agent utilizing a Subflow

We will utilize an existing Agent that has been made available for download here. Go ahead and restore the sample Agent into an Agent project following the steps given over here. Once you have restored the agent, you should be able to see the sample flow that is shown below:

 

The Sample agent has our default flow and the agent currently supports queries in two different areas:

  • Get Information on Store Hours
  • Sign up for Deals

You can try out the Agent by using the Test Agent feature in Dialogflow CX console with the following phrases:

  • What are the store hours? (Store Hours page)
  • Are there any deals currently on? (Signup for Deals page)

Understanding the Subflow

Our interest in this blog post, will be on the Signup for Deals page that allows users to sign up for receiving deals on their email address. You will notice that there is a subflow Collect User Information, that is being invoked by one of the routes from Signup for Deals page. Let us take a look at this flow, which is shown below:

Read More  How Managed Security Service Providers Can Accelerate Their Business With Google Cloud Security’s Partner Program Using Google Chronicle

 

This subflow captures three inputs (parameters) from the user:

  • First Name
  • Last Name
  • Email Address

This is evident from the Collect User Information page and the parameter settings as shown below:

 

Additionally, we have a Route setup from this page that fires if the parameters (all of them are mandatory) have been captured and when that happens, we set a parameter personal-details-collected to “DONE” and end this flow, as shown below:

 

You can think of this subflow as a common piece of functionality that you might require in more scenarios across this Agent or in other projects. We do not want to reinvent the wheel and script this every time that we need to capture these common parameters from the user.

In essence, we are going to call the Collect User Information flow, which captures the parameters and then the parameters will need to be read in the Default Start flow, which is the parent flow.

Understanding Parent Flow

Now that we have looked at the subflow, the Parent Flow should be easy to understand. You noticed in the earlier section that we set a parameter personal-details-collected to “DONE”. So just before we transition to the subflow, the Signup for Deals page sets the parameter to PENDING as shown below.

 

Once we return from the subflow, there are two routes for this page as given below:

 

One of them goes forward to the Display Information Page if the parameters are collected. The other one again routes to the same same subflow: Collect User Information Flow. The latter should ideally not come up since in our example, we have made all the parameters for the user to be mandatory. But in case, you did not have them mandatory and had to check in the parent flow, if the parameters were provided, going back to the Subflow would have made more appropriate vis-a-vis the user experience.

Read More  Google Cloud VMware Engine Is Now Generally Available

Finally, we have the Display Information Page, which simply captures the parameter values from the session and displays them. This is more of a check at this point to help us understand that the subflow was integrated and is working well.

 

Test the Agent

A sample Test Run of the Agent is shown below, where we exercise the route that will invoke the Capture User Information subflow. The parameters captured in that flow are then read back as session parameters in the parent flow and displayed.

 

During the Test Run, be sure to check out the Parameters section as shown below. The parameters get populated accordingly and is a good way to check during the development process if everything is going as expected.

 

Reusing subflows is an important aspect to ensure that you are able to capture common functionality and then reuse it across Agents. This will ease the development of Agents that are complex and where multiple teams are responsible for different flows of the Agent.

Feel free to reach out to me on Twitter @iRomin for any questions or feedback.

References

  • Sample Agent File
  • Dialogflow CX Documentation
  • Dialogflow CX Flows

 

 

By: Romin Irani (Developer Advocate)
Source: Google Cloud Blog


Our humans need coffee too! Your support is highly appreciated, thank you!

aster_cloud

Related Topics
  • Dialogflow
  • Dialogflow CX
  • Google Cloud
  • Subflow
  • Tutorial
You May Also Like
View Post
  • Architecture
  • Data
  • Engineering
  • People
  • Programming
  • Software Engineering
  • Technology

Predictions: Top 25 Careers Likely In High Demand In The Future

  • June 6, 2023
View Post
  • Design
  • Engineering

Building A Kubernetes Platform: How And Why To Apply Governance And Policy

  • June 4, 2023
View Post
  • Computing
  • Design
  • Engineering
  • Multi-Cloud

Amazing Federated Multicloud Apps

  • June 2, 2023
View Post
  • Engineering

Resolving Deployment Issues With Ts-node And Azure Development Pipelines

  • June 1, 2023
View Post
  • Design
  • Engineering

Four Steps To Managing Your Cloud Logging Costs On A Budget

  • May 31, 2023
View Post
  • Engineering
  • Tools

Red Hat Puts Podman Container Management On The Desktop

  • May 30, 2023
View Post
  • Engineering
  • Practices
  • Tools

Tricentis Launches Quality Engineering Community ShiftSync

  • May 23, 2023
View Post
  • Programming
  • Software Engineering
  • Technology

Build a Python App to Alert You When Asteroids Are Close to Earth

  • May 22, 2023

Stay Connected!
LATEST
  • 1
    Microsoft Offers Azure ML Data Import CLI, SDK For Snowflake, Other Databases
    • June 8, 2023
  • 2
    Why Are Humans Afraid Of AI?
    • June 7, 2023
  • 3
    The Technical Architecture And Components Of A.I. Systems
    • June 7, 2023
  • 4
    Nature Already Inspired A.I. Than Most Realise
    • June 7, 2023
  • 5
    “A Field Guide To AI: For Business, Institutions, Society & Political Economy” — Your Essential Companion In Navigating the World of Artificial Intelligence.
    • June 7, 2023
  • 6
    Predictions: Top 25 Careers Likely In High Demand In The Future
    • June 6, 2023
  • 7
    A S.W.O.T. Analysis Of Current A.I. Systems
    • June 6, 2023
  • Apple-WWCD23-Vision-Pro-glass-230605 8
    Introducing Apple Vision Pro: Apple’s first spatial compute
    • June 5, 2023
  • 9
    Apple Unveils New Mac Studio And Brings Apple Silicon To Mac Pro
    • June 5, 2023
  • 10
    Apple Introduces M2 Ultra
    • June 5, 2023
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    tvOS 17 Brings FaceTime And Video Conferencing To The Biggest Screen In The Home
    • June 5, 2023
  • 2
    Apple Introduces The 15‑Inch MacBook Air
    • June 5, 2023
  • 3
    Huawei ICT Competition 2022-2023 Global Final Held In Shenzhen — 146 Teams From 36 Countries And Regions Win Awards
    • May 27, 2023
  • 4
    Building A Kubernetes Platform: How And Why To Apply Governance And Policy
    • June 4, 2023
  • 5
    Leave, This “United” “Kingdom”, This “Great” “Britain”
    • June 4, 2023
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.