aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • 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
    • Learning
  • 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.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

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  Siemens Accelerates Innovation At The Factory Edge With Red Hat OpenShift

 

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  MLOps System With AutoML And Pipeline In Vertex AI

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


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

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
  • Engineering

Just make it scale: An Aurora DSQL story

  • May 29, 2025
View Post
  • Engineering
  • Technology

Guide: Our top four AI Hypercomputer use cases, reference architectures and tutorials

  • March 9, 2025
View Post
  • Software Engineering
  • Technology

Claude 3.7 Sonnet and Claude Code

  • February 25, 2025
View Post
  • Computing
  • Engineering

Why a decades old architecture decision is impeding the power of AI computing

  • February 19, 2025
View Post
  • Engineering
  • Software Engineering

This Month in Julia World

  • January 17, 2025
View Post
  • Engineering
  • Software Engineering

Google Summer of Code 2025 is here!

  • January 17, 2025
View Post
  • Data
  • Engineering

Hiding in Plain Site: Attackers Sneaking Malware into Images on Websites

  • January 16, 2025
View Post
  • Computing
  • Design
  • Engineering
  • Technology

Here’s why it’s important to build long-term cryptographic resilience

  • December 24, 2024

Stay Connected!
LATEST
  • 1
    The Summer Adventures : Hiking and Nature Walks Essentials
    • June 2, 2025
  • 2
    Just make it scale: An Aurora DSQL story
    • May 29, 2025
  • 3
    Reliance on US tech providers is making IT leaders skittish
    • May 28, 2025
  • Examine the 4 types of edge computing, with examples
    • May 28, 2025
  • AI and private cloud: 2 lessons from Dell Tech World 2025
    • May 28, 2025
  • 6
    TD Synnex named as UK distributor for Cohesity
    • May 28, 2025
  • Weigh these 6 enterprise advantages of storage as a service
    • May 28, 2025
  • 8
    Broadcom’s ‘harsh’ VMware contracts are costing customers up to 1,500% more
    • May 28, 2025
  • 9
    Pulsant targets partner diversity with new IaaS solution
    • May 23, 2025
  • 10
    Growing AI workloads are causing hybrid cloud headaches
    • May 23, 2025
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
  • Understand how Windows Server 2025 PAYG licensing works
    • May 20, 2025
  • By the numbers: How upskilling fills the IT skills gap
    • May 21, 2025
  • 3
    Cloud adoption isn’t all it’s cut out to be as enterprises report growing dissatisfaction
    • May 15, 2025
  • 4
    Hybrid cloud is complicated – Red Hat’s new AI assistant wants to solve that
    • May 20, 2025
  • 5
    Google is getting serious on cloud sovereignty
    • May 22, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.