Create Reusable Workflow Steps with Sub-Workflows
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:
- Create parent workflow → Add trigger and initial steps
- Add Call Sub-Workflow action → Configure parameters to pass
- Create Sub-Workflow in new tab → Set Sub-Workflow trigger
- Click “Capture Response” → Sub-Workflow listens for data
- Test parent workflow action → Sends test data to Sub-Workflow
- Sub-Workflow captures parameters → Now has the data structure
- Build Sub-Workflow actions → Process the captured data
- Add Return Response → Send results back to parent
- 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
- In WordPress admin, navigate to FlowMattic → Workflows
- Click Create New Workflow
- Name it: “Gravity Forms to CRM” (this is our parent workflow)
- Click Save
Step 2: Add Your Trigger
For this example, let’s use a Gravity Forms trigger:
- Click Choose Trigger App
- Select Gravity Forms
- Choose New Form Response as the trigger event
- Connect your Gravity account and select your form
- 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:
- Click Add New Step
- Search for and select Sub-Workflow
- Choose Call Sub-Workflow action
- Click Continue
Step 4: Configure Parameters to Pass
Now define what data you want to send to the Sub-Workflow:
- Click Add Parameter in the Call Sub-Workflow action
- Add your first parameter:
- Key:
customer_email - Value: Map to
{trigger.email_address}from your form
- Key:
- Click Add Parameter again
- Add second parameter:
- Key:
customer_phone - Value: Map to
{trigger.phone_number}from your form
- Key:
- Add third parameter:
- Key:
customer_name - Value: Map to
{trigger.full_name}from your form
- Key:
Parameter naming best practices:
- Use lowercase with underscores (snake_case):
customer_emailnotCustomerEmail - Be descriptive:
order_totalnot justtotal - 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.
- Right-click FlowMattic → Workflows and open in a new tab
- In the new tab, click Create New Workflow
- 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
- Click Choose Trigger App
- Select Sub-Workflow
- Choose Start Sub-Workflow as the trigger event
- Click Continue
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:
- In the Sub-Workflow trigger settings, click Capture Response button
- This puts the Sub-Workflow in “listening mode”
- You’ll see a message: “Waiting to capture request from parent workflow…”
- Keep this tab open
Step 8: Go Back to Parent Workflow and Test
- Switch back to your parent workflow tab
- Scroll to the Call Sub-Workflow action
- Click Test Action
- The parent workflow will send the test data to your Sub-Workflow
Step 9: Return to Sub-Workflow to See Captured Data
- Switch back to your Sub-Workflow tab
- You should see: “Request captured successfully!”
- The Sub-Workflow now has the parameters captured:
customer_emailcustomer_phonecustomer_name
- 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
- Click Add New Step
- Select Text Formatter
- Choose Lowercase action
- In the Text field, insert:
{customer_email}(available from captured parameters) - Click Save
Action 2: Remove Email Whitespace
- Add another step
- Select Text Formatter
- Choose Trim Whitespace action
- In the Text field, insert the output from Action 1
- Click Save
Action 3: Format Phone Number
- Add another step
- Select Text Formatter
- Choose Extract Numbers action
- In the Text field, insert:
{customer_phone} - This removes all non-numeric characters:
(555) 123-4567becomes5551234567
Action 4: Proper Case Name
- Add another step
- Select Text Formatter
- Choose Title Case action
- In the Text field, insert:
{customer_name} - This converts
john doeorJOHN DOEtoJohn Doe
Step 11: Add the Return Response Action
CRITICAL: Every Sub-Workflow must end with a Return Response action.
- Click Add New Step
- Select Sub-Workflow
- Choose Return Response action
- Click Continue
Now define what data to send back to the parent workflow:
- Click Add Response Parameter
- Add first response:
- Key:
formatted_email - Value: Insert the output from Action 2 (the trimmed, lowercase email)
- Key:
- Add second response:
- Key:
formatted_phone - Value: Insert the output from Action 3 (numbers only)
- Key:
- Add third response:
- Key:
formatted_name - Value: Insert the output from Action 4 (title case name)
- Key:
Step 12: Save and Enable the Sub-Workflow
- Click Save Workflow
- Important: Toggle the workflow status to ON (enabled)
- 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
- Switch back to your parent workflow tab
- In the Call Sub-Workflow action, click the Sub-Workflow dropdown
- You should now see “Format Customer Contact Info” in the list
- Select it
- 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:
- Click Add New Step after the Call Sub-Workflow action
- Select your CRM app (HubSpot, Salesforce, etc.)
- Choose Create Contact action
- Map the fields using the returned data:
- Email:
{sub_workflow.formatted_email} - Phone:
{sub_workflow.formatted_phone} - Name:
{sub_workflow.formatted_name}
- Email:
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
- Click Test Workflow on the parent workflow
- Submit a test form response
- Watch the execution:
- Parent workflow triggers
- Calls Sub-Workflow with parameters
- Sub-Workflow processes data
- Returns formatted data
- Parent workflow creates CRM contact
- 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
- Navigate to FlowMattic → Workflows
- Click Create New Workflow
- Name it: “FluentCart Orders to CRM”
- Set trigger to FluentCart → New Order
- Configure and test the trigger
Step 2: Add Call Sub-Workflow Action
- Click Add New Step
- Select Sub-Workflow
- Choose Call Sub-Workflow action
- 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:
- customer_email: Map to
{trigger.customer.email} - customer_phone: Map to
{trigger.customer.phone} - 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
- Add a new step
- Select your CRM app
- Choose Update or Create Contact action
- Map fields:
- Email:
{sub_workflow.formatted_email} - Phone:
{sub_workflow.formatted_phone} - Name:
{sub_workflow.formatted_name}
- Email:
Step 5: Save and Test
- Save the workflow
- Enable it
- 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}
- Key:
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:
- Go to FlowMattic → Workflows
- Find the Sub-Workflow mentioned in the error
- Click the toggle to turn it ON
- 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