Create a subflow

Create a subflow

What is a subflow? 

A subflow is a set of actions or logic that you can reuse across multiple flows. Imagine you have several workflows that follow the same set of actions or logic elements. Repeating those steps in every workflow can be time-consuming and inefficient. Instead of recreating the same set of steps in multiple flows, you can build them once in a subflow, then use that subflow as a simple drag-and-drop action wherever needed. This saves both time and effort.

Here are a couple of use cases:

Use case 1: Whenever a new lead is captured, you might want to verify whether the email address already exists in your CRM as a contact. Instead of duplicating this logic for leads coming in from different sources, you can create a subflow that handles this verification. The parent flow passes the lead's Email Address to the subflow, which checks for a matching contact and returns the result like 'Exists' or Doesn't exist'. Based on this output, the parent flow can decide whether to update the existing contact or create a new one.
Use case 2: You run an online store where each confirmed order requires sending an invoice email to the customer. This step involves fetching customer details by matching the contact number and sending an email. Instead of manually repeating this process, you can create a subflow that automatically fetches customer details and sends the invoice email. Whenever a new order is placed, the parent flow can call this subflow (by simply passing the customer contact number) to handle the task.
This set of actions needs to be repeated in other flows as well, for order returns and other scenarios where there's a need to generate and send an invoice to a customer. Creating a reusable subflow not only avoids duplication, but also ensures consistency and easier maintenance across various use cases.

Components of a subflow

A subflow receives input data from a parent flow (the flow that calls the subflow), and can be configured to return output back to the parent flow.
Each subflow consists of:
  1. Subflow trigger: You can define the input parameters received from the parent flow and the output parameters to be sent back.
  2. Actions: Similar to a regular flow, a subflow can include one or more actions, decision blocks, and logic elements.
  3. Return data(Optional): If you've configured your parent flow to call a subflow and wait for its output, you need to return results back to the parent. Use this action to send the output, so it can be used in the subsequent steps of the parent flow.

Steps to build a subflow

Follow these steps to create and configure a subflow for reuse in other flows.

Configure a subflow

  1. On the MyFlows page, click Create Flow, enter a flow name, and click Create.
  2. Click Configure in the Subflow box.
  3. In the configuration window that appears, define the input parameters (the data/the fields this subflow needs from the parent flow) and output parameters (the data/the fields this subflow returns to the parent flow).



  4. Click the ➕ icon to add multiple parameters. You can use the ✖ icon to remove any unneeded parameters.
  5. Once you've added the required input and output parameters, click Done.

Add actions

You can add as many actions as required to the subflow. You can also add decision blocks or other logic elements to customize the subflow's behaviour.

The last component of a subflow is an optional Return data action. It collects data from all preceding actions and sends it to the parent flow. Add this action if you want to return output to the parent flow.
  1. In the Builder, navigate to Logic > Flow Control and select Return data.
  2. In the configuration window, choose the Subflow execution status that should be returned to the parent flow. All output fields defined in the subflow will be displayed here. You can either enter the values or map the values to be returned for each field based on whether the status is Success or Failure.

    For example, if the subflow defines five output variables, and the subflow returns all of them on Success and only one on Failure
    , then:
    • On Success: The five specified variables will return their respective values.

    • On Failure: The one specified variable will return its value, while the other four will return null.


    In short, all output variables declared in the subflow will appear in every Return data container,
    regardless of whether they are populated or return null.
    Example:
    • On Success: Return values of Status, Subflow Case, Provided Client Name, Created Client Name, and Date

    • On Failure: Only return the Status value



  3. Click Done.

Steps to call a subflow

To reuse the actions defined in a subflow, you can call it directly from the parent flow.
  1. In the Builder, navigate to Logic > Flow Control and drag and drop Call a subflow to attach your subflow to the required action in the parent flow.
  2. In the configuration window that appears, choose the Subflow you want to call from the parent flow.
  3. Select a value for the Subflow Execution Behavior based on whether the subsequent actions in the parent flow require the return value from the subflow.
      • Wait and continue: The parent flow calls the subflow and waits for it to finish and return a result.

      • Continue without waiting: The parent flow continues executing without waiting for the subflow to complete.

  4. You can either manually enter values for the input fields or map values from the Insert variable section in the right panel. These input fields are defined in the subflow and are required for the subflow to run as expected.



  5. Click Done.



Notes
The 'Call a subflow' action is not enabled in a subflow, and the 'Return data' action is not enabled in a parent flow.
If you select the Wait and continue option under Subflow Execution Behavior, ensure that you include a Return data action in your subflow. This is important because the parent flow will pause and wait for the subflow to finish before proceeding, and the Return data action is needed to send the result back from the subflow to the parent flow.


Info
  1. Make sure to switch on all subflows used by the parent flow before turning on the parent flow to avoid interruptions.
  2. You can't switch off a subflow if it's used in either a live or paused flow.
  3. If you've configured your parent flow to call a subflow and wait for its output, make sure to include a 'Return data' action in the subflow.
  4. When you restart or resume a parent flow, its associated subflows are also restarted or resumed. However, restarting or resuming a subflow alone does not affect the parent flow that uses it.
  5. When a subflow fails, resuming the parent flow after changing input values will restart the subflow instead of resuming it from the failed step. You can view the execution status from the History section.
  6. If you want to switch off a subflow that is currently switched on, you'll need to go back to the parent flow that uses it, delete the 'Call a Subflow' action, then switch off the subflow.