Articles in this section
Category / Section

Create Reusable Workflow Steps with Sub-Workflows

8 mins read
Updated:

Ready to supercharge your FlowMattic workflows? This guide walks you through creating and using Sub-Workflows step by step. By the end, you’ll have built your first reusable workflow component.

Before You Start

What you’ll learn:

  • How to build a Sub-Workflow from scratch
  • How to pass data to Sub-Workflows
  • How to return data from Sub-Workflows
  • How to call Sub-Workflows from parent workflows
  • Best practices and troubleshooting tips

What you’ll need:

  • WordPress site with FlowMattic plugin installed
  • Access to FlowMattic dashboard in WordPress admin
  • Basic familiarity with creating FlowMattic workflows
  • 15 minutes to follow along

Important Note: FlowMattic is a WordPress plugin, so you’ll be working within your WordPress admin dashboard throughout this tutorial.

The FlowMattic Sub-Workflow Process

FlowMattic has a unique approach to creating Sub-Workflows. Here’s the high-level process:

  1. Create parent workflow → Add trigger and initial steps
  2. Add Call Sub-Workflow action → Configure parameters to pass
  3. Create Sub-Workflow in new tab → Set Sub-Workflow trigger
  4. Click “Capture Response” → Sub-Workflow listens for data
  5. Test parent workflow action → Sends test data to Sub-Workflow
  6. Sub-Workflow captures parameters → Now has the data structure
  7. Build Sub-Workflow actions → Process the captured data
  8. Add Return Response → Send results back to parent
  9. Complete parent workflow → Use returned data

Why this order? It makes parameter passing automatic and error-free. The Sub-Workflow captures exactly what the parent sends.


Part 1: Create Your Parent Workflow First

Unlike some automation platforms, FlowMattic has a unique workflow for setting up Sub-Workflows. You’ll start with the parent workflow, then create the Sub-Workflow. This approach makes parameter passing easier and more intuitive.

Let’s create a practical example: a Sub-Workflow that formats customer contact information.

Step 1: Create the Parent Workflow

  1. In WordPress admin, navigate to FlowMattic → Workflows
  2. Click Create New Workflow
  3. Name it: “Gravity Forms to CRM” (this is our parent workflow)
  4. Click Save

Step 2: Add Your Trigger

For this example, let’s use a Gravity Forms trigger:

  1. Click Choose Trigger App
  2. Select Gravity Forms
  3. Choose New Form Response as the trigger event
  4. Connect your Gravity account and select your form
  5. Test the trigger to ensure data is coming through

Step 3: Add the Call Sub-Workflow Action

Here’s where it gets interesting. You’ll add the Sub-Workflow call action BEFORE creating the actual Sub-Workflow:

  1. Click Add New Step
  2. Search for and select Sub-Workflow
  3. Choose Call Sub-Workflow action
  4. Click Continue

Step 4: Configure Parameters to Pass

Now define what data you want to send to the Sub-Workflow:

  1. Click Add Parameter in the Call Sub-Workflow action
  2. Add your first parameter:
    • Key: customer_email
    • Value: Map to {trigger.email_address} from your form
  3. Click Add Parameter again
  4. Add second parameter:
    • Key: customer_phone
    • Value: Map to {trigger.phone_number} from your form
  5. Add third parameter:
    • Key: customer_name
    • Value: Map to {trigger.full_name} from your form

call-sub-workflow-action.png

Parameter naming best practices:

  • Use lowercase with underscores (snake_case): customer_email not CustomerEmail
  • Be descriptive: order_total not just total
  • Group related parameters with prefixes: customer_email, customer_name, customer_phone

Important: Don’t test this action yet. We need to create the Sub-Workflow first.


Part 2: Create the Sub-Workflow

Now you’ll create the actual Sub-Workflow that will process this data.

Step 5: Open New Tab and Create Sub-Workflow

Keep your parent workflow tab open! You’ll need to switch between tabs.

  1. Right-click FlowMattic → Workflows and open in a new tab
  2. In the new tab, click Create New Workflow
  3. Name it descriptively: “Format Customer Contact Info”
    • Good names: “Format Customer Data”, “Validate Email Address”, “Calculate Shipping Cost”
    • Avoid: “Sub-Workflow 1”, “Helper”, “Utility”

Why naming matters: This name appears in dropdowns and helps you identify the workflow’s purpose.

Step 6: Set the Sub-Workflow Trigger

  1. Click Choose Trigger App
  2. Select Sub-Workflow
  3. Choose Start Sub-Workflow as the trigger event
  4. Click Continue

sub-workflow - trigger step.png

This tells FlowMattic this workflow will be called by other workflows.

Step 7: Click “Capture Response”

This is the crucial step that makes FlowMattic unique:

  1. In the Sub-Workflow trigger settings, click Capture Response button
  2. This puts the Sub-Workflow in “listening mode”
  3. You’ll see a message: “Waiting to capture request from parent workflow…”
  4. Keep this tab open

Step 8: Go Back to Parent Workflow and Test

  1. Switch back to your parent workflow tab
  2. Scroll to the Call Sub-Workflow action
  3. Click Test Action
  4. The parent workflow will send the test data to your Sub-Workflow

Step 9: Return to Sub-Workflow to See Captured Data

  1. Switch back to your Sub-Workflow tab
  2. You should see: “Request captured successfully!”
  3. The Sub-Workflow now has the parameters captured:
    • customer_email
    • customer_phone
    • customer_name
  4. Click Save to store the captured structure

What just happened? The parent workflow sent test data, and the Sub-Workflow captured the parameter structure. Now you can use these parameters in your Sub-Workflow actions.

Step 10: Add Your Processing Actions

Now build the logic to process the captured data:

Action 1: Clean Email Address

  1. Click Add New Step
  2. Select Text Formatter
  3. Choose Lowercase action
  4. In the Text field, insert: {customer_email} (available from captured parameters)
  5. Click Save

Action 2: Remove Email Whitespace

  1. Add another step
  2. Select Text Formatter
  3. Choose Trim Whitespace action
  4. In the Text field, insert the output from Action 1
  5. Click Save

Action 3: Format Phone Number

  1. Add another step
  2. Select Text Formatter
  3. Choose Extract Numbers action
  4. In the Text field, insert: {customer_phone}
  5. This removes all non-numeric characters: (555) 123-4567 becomes 5551234567

Action 4: Proper Case Name

  1. Add another step
  2. Select Text Formatter
  3. Choose Title Case action
  4. In the Text field, insert: {customer_name}
  5. This converts john doe or JOHN DOE to John Doe

Step 11: Add the Return Response Action

CRITICAL: Every Sub-Workflow must end with a Return Response action.

  1. Click Add New Step
  2. Select Sub-Workflow
  3. Choose Return Response action
  4. Click Continue

Now define what data to send back to the parent workflow:

  1. Click Add Response Parameter
  2. Add first response:
    • Key: formatted_email
    • Value: Insert the output from Action 2 (the trimmed, lowercase email)
  3. Add second response:
    • Key: formatted_phone
    • Value: Insert the output from Action 3 (numbers only)
  4. Add third response:
    • Key: formatted_name
    • Value: Insert the output from Action 4 (title case name)

return-response.png

Step 12: Save and Enable the Sub-Workflow

  1. Click Save Workflow
  2. Important: Toggle the workflow status to ON (enabled)
  3. The Sub-Workflow is now ready to be called

Part 3: Complete the Parent Workflow

Now go back to your parent workflow and finish it.

Step 13: Verify the Sub-Workflow Connection

  1. Switch back to your parent workflow tab
  2. In the Call Sub-Workflow action, click the Sub-Workflow dropdown
  3. You should now see “Format Customer Contact Info” in the list
  4. Select it
  5. Verify your parameters are still mapped correctly

Step 14: Use the Returned Data

The Sub-Workflow will now return formatted data. Let’s use it to create a CRM contact:

  1. Click Add New Step after the Call Sub-Workflow action
  2. Select your CRM app (HubSpot, Salesforce, etc.)
  3. Choose Create Contact action
  4. Map the fields using the returned data:
    • Email: {sub_workflow.formatted_email}
    • Phone: {sub_workflow.formatted_phone}
    • Name: {sub_workflow.formatted_name}

Notice the prefix: All returned data from Sub-Workflows uses {sub_workflow.your_key_name}

Note: The dynamic tags used in this article are for representative purpose only. You should use the dynamic tag selection dropdown and choose the tag wisely.

Step 15: Test the Complete Workflow

  1. Click Test Workflow on the parent workflow
  2. Submit a test form response
  3. Watch the execution:
    • Parent workflow triggers
    • Calls Sub-Workflow with parameters
    • Sub-Workflow processes data
    • Returns formatted data
    • Parent workflow creates CRM contact
  4. Check your CRM to verify the contact was created with formatted data

Congratulations! You’ve created your first working Sub-Workflow in FlowMattic.


Part 4: Reuse Your Sub-Workflow in Other Workflows

The real power of Sub-Workflows comes from reusing them. Let’s create another parent workflow that uses the same Sub-Workflow.

Example: FluentCart Orders to CRM

Same Sub-Workflow, different data source. This shows the power of reusability.

Step 1: Create New Parent Workflow

  1. Navigate to FlowMattic → Workflows
  2. Click Create New Workflow
  3. Name it: “FluentCart Orders to CRM”
  4. Set trigger to FluentCart → New Order
  5. Configure and test the trigger

Step 2: Add Call Sub-Workflow Action

  1. Click Add New Step
  2. Select Sub-Workflow
  3. Choose Call Sub-Workflow action
  4. In the dropdown, select “Format Customer Contact Info” (your existing Sub-Workflow)

Step 3: Map Different Parameters

Now map the FluentCart data to the same Sub-Workflow parameters:

  1. customer_email: Map to {trigger.customer.email}
  2. customer_phone: Map to {trigger.customer.phone}
  3. customer_name: Map to {trigger.customer.first_name} {trigger.customer.last_name}

Notice: Same parameter names, different data sources. The Sub-Workflow doesn’t care where the data comes from.

Step 4: Use the Returned Data

  1. Add a new step
  2. Select your CRM app
  3. Choose Update or Create Contact action
  4. Map fields:
    • Email: {sub_workflow.formatted_email}
    • Phone: {sub_workflow.formatted_phone}
    • Name: {sub_workflow.formatted_name}

Step 5: Save and Test

  1. Save the workflow
  2. Enable it
  3. Test with a real or test FluentCart order

Result: Same Sub-Workflow, different trigger, same reliable formatting logic. If you need to change how phone numbers are formatted, update the Sub-Workflow once and both parent workflows instantly use the new logic.


Understanding the Workflow Flow

Here’s what happens when a parent workflow runs:

1. Parent Workflow Trigger Fires
   (Gravity Form submitted, FluentCart order created, etc.)
   ↓
2. Parent Workflow Actions Execute
   (Any steps before the Sub-Workflow call)
   ↓
3. Call Sub-Workflow Action Sends Data
   Parameters: customer_email, customer_phone, customer_name
   ↓
4. Sub-Workflow Receives Parameters
   Trigger: Start Sub-Workflow captures the data
   ↓
5. Sub-Workflow Actions Execute
   Format email → Trim spaces → Format phone → Format name
   ↓
6. Sub-Workflow Returns Response
   Returns: formatted_email, formatted_phone, formatted_name, status
   ↓
7. Parent Workflow Receives Response
   Data available as {sub_workflow.key_name}
   ↓
8. Parent Workflow Continues
   Uses returned data in subsequent steps
   ↓
9. Parent Workflow Completes

Using Dynamic Return Values

You don’t have to return static keys. Build them dynamically:

Example: Return processed item count

  • Action step: Count items in a list → Result: 5
  • Return Response:
    • Key: items_processed
    • Value: {count_step.result}

Nesting Sub-Workflows

Sub-Workflows can call other Sub-Workflows (but avoid circular references):

✅ Allowed:

  • Sub-Workflow A calls Sub-Workflow B
  • Sub-Workflow C calls Sub-Workflow B
  • Sub-Workflow A calls Sub-Workflow C

❌ Not Allowed:

  • Sub-Workflow A calls Sub-Workflow B
  • Sub-Workflow B calls Sub-Workflow A
  • (This creates an infinite loop)

Best Practices

Design for Reusability

Do:

  • Keep Sub-Workflows focused on one task
  • Use generic parameter names when possible
  • Think about all potential use cases upfront
  • Document what parameters expect

Don’t:

  • Hardcode specific values
  • Make “mega Sub-Workflows” that do everything
  • Use workflow-specific logic

Naming Conventions

Parameters and return keys:

✅ Good: customer_email, order_total, is_valid
❌ Avoid: email, total, valid

Why? Descriptive names prevent confusion when you have multiple Sub-Workflows.


Troubleshooting Common Issues

Issue: “Capture Response” Not Working

Possible causes:

  • Parent workflow not set up correctly
  • Sub-Workflow not in listening mode

Solutions:

  • ✅ Ensure you clicked “Capture Response” in the Sub-Workflow BEFORE testing parent workflow
  • ✅ Keep the Sub-Workflow tab open and visible while testing parent
  • ✅ Check that the Call Sub-Workflow action has parameters configured
  • ✅ Try refreshing both browser tabs and start over

Issue: Sub-Workflow Not Appearing in Dropdown

Solutions:

  • ✅ Ensure the Sub-Workflow has “Start Sub-Workflow” trigger
  • ✅ Verify the Sub-Workflow is saved and enabled (toggle is ON)
  • ✅ Refresh the parent workflow page
  • ✅ Clear WordPress cache if using a caching plugin

Issue: Parameters Not Available in Sub-Workflow

Check:

  • ✅ Did you complete the “Capture Response” step successfully?
  • ✅ Did you test the Call Sub-Workflow action in parent workflow?
  • ✅ Are you using the correct parameter names (case-sensitive)?
  • ✅ Check the Sub-Workflow trigger settings to see captured parameters

Issue: No Data Returned to Parent Workflow

Check:

  • ✅ Return Response action is added to Sub-Workflow
  • ✅ Return Response is the last step in Sub-Workflow
  • ✅ Return Response parameters have valid values mapped
  • ✅ Sub-Workflow is enabled and saved
  • ✅ Sub-Workflow isn’t failing before Return Response step

Issue: “Sub-workflow is currently disabled” Error

Solution:

  1. Go to FlowMattic → Workflows
  2. Find the Sub-Workflow mentioned in the error
  3. Click the toggle to turn it ON
  4. Return to parent workflow and test again

Issue: Parent Workflow Fails After Sub-Workflow Call

Check:

  • ✅ Using correct return key names: {sub_workflow.key_name}
  • ✅ Return keys match exactly what you defined (case-sensitive)
  • ✅ Sub-Workflow completed successfully (check execution logs)
  • ✅ Returned data type matches expected type in parent workflow

Issue: “Circular dependency detected” Error

Solution:
Your Sub-Workflow structure creates an infinite loop:

  • Sub-Workflow A calls Sub-Workflow B
  • Sub-Workflow B calls Sub-Workflow A

Restructure your workflows to break the circular reference.

Issue: Parameters Have Wrong Data

Check:

  • ✅ Parameter mapping in parent workflow is correct
  • ✅ Using the right trigger fields (check field names)
  • ✅ Data exists in the trigger (test trigger first)
  • ✅ No typos in parameter keys

Need help? Visit FlowMattic Support or contact our support team.


Related Articles:

  • Understanding Sub-Workflows in FlowMattic
  • FlowMattic Sub-Workflows and How to Use Them
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied