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  Google I/O 2019 | What's New in Android

 

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  SUSE Linux Enterprise Server (SLES) With 24/7 Support - Now Available With Committed Use Discounts

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
  • 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
IBM and Ferrari Premium Partner
View Post
  • Data
  • Engineering

IBM Selected as Official Fan Engagement and Data Analytics Partner for Scuderia Ferrari HP

  • November 7, 2024

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • 3
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 4
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 5
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 6
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 7
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 8
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 9
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
  • 10
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 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
  • 1
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 2
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 3
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 4
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • Nintendo Switch Deals on Amazon 5
    10 Physical Nintendo Switch Game Deals on MAR10 Day!
    • March 9, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.