tr Skip to content
Black Friday FlowMattic for life, 12 payments of $33.25 Or $399 once. Nothing added for splitting Ends in --Days --Hrs --Min --Sec See the deal

Reusable Sub-Workflow: Build Steps Once, Call Them Anywhere

FlowMattic Sub-Workflow: a parent workflow calls a shared sub-workflow with parameters and maps the response it returns.

A reusable sub-workflow lets you build a sequence of steps once and call it from any other workflow. In FlowMattic, the Sub-Workflow app does this with a trigger and two actions: the parent workflow passes in parameters, the sub-workflow does its work, and it hands a response back that the parent’s next steps can map.

If several of your workflows repeat the same ten steps (create the customer, tag them, log the event), every change means editing each copy. A sub-workflow puts that logic in one place. It is for anyone whose automation library has grown past a handful of workflows, and for agencies that rebuild the same building blocks for many clients.

What is a sub-workflow?

A sub-workflow is an ordinary FlowMattic workflow that starts with the Start Sub-Workflow trigger instead of a webhook or an app event. It runs only when another workflow calls it. The Sub-Workflow app provides three events:

EventTypeWhere it goes
Start Sub-WorkflowTriggerFirst step of the sub-workflow. Fires when a parent calls it.
Call Sub-WorkflowActionIn the parent. Runs the sub-workflow and receives its response.
Return ResponseActionLast step of the sub-workflow. Sends data back to the parent.

Workflows with the Start Sub-Workflow trigger are marked automatically when saved, and carry a SUB badge in the workflow list and in Task History. In the app picker, the Sub-Workflow app sits in Flow Controls: “Build and call reusable workflow components.” It belongs with the other workflow logic modules.

How to build a reusable sub-workflow

1. Create the sub-workflow

In a parent workflow, add a Call Sub-Workflow step and click Create New Sub-Workflow (or + Create New Sub-Workflow if you already have some). A new workflow opens with the Start Sub-Workflow trigger and a Return Response step already in place. Add your shared steps between them.

2. Define what the parent passes in

Back in the parent, the Call Sub-Workflow step has two parts. Select Sub-Workflow lists only workflows that use the Start Sub-Workflow trigger. Parameters to Pass is a list of key and value pairs, each value typed or mapped from earlier steps. A value that contains JSON is passed as structured data, not text.

FlowMattic Call Sub-Workflow step Configure tab showing the Select Sub-Workflow dropdown and Parameters to Pass key/value rows.
A Call Sub-Workflow step in a parent workflow, with Select Sub-Workflow and the Parameters to Pass list.

3. Capture sample data in the sub-workflow

To map the parameters inside the sub-workflow, it needs sample data. Put the sub-workflow’s trigger into capture mode, then test the Call Sub-Workflow step in the parent. Instead of running the sub-workflow, FlowMattic stores the parameters as the trigger’s sample and replies “Sub-workflow trigger data captured successfully.” Each key you passed is now a field in the sub-workflow.

4. Return a response

In the sub-workflow’s Return Response step, fill Response Data with the keys the parent needs, such as a customer ID or a status. This should be the last step of the sub-workflow.

5. Use the result in the parent

When the parent runs, Call Sub-Workflow runs the sub-workflow and returns each Response Data key, plus sub_workflow_id and sub_workflow_name. Map those into the parent’s next steps like any other step output. If the sub-workflow has no Return Response, the step reports “Sub-workflow executed successfully but returned no response.”

Built-in safeguards

  • Circular calls are blocked. If a sub-workflow would end up calling itself, directly or through another sub-workflow, the step fails with “Circular dependency detected.”
  • Disabled sub-workflows don’t run. Calling a sub-workflow that is switched off returns “Sub-workflow is currently disabled. Please enable it before calling.”
  • Deleted sub-workflows are reported. If the selected sub-workflow no longer exists, the step reports that it was not found.
  • Each run is logged separately. The sub-workflow’s run appears in Task History under its own name with the SUB badge, so you can debug it on its own.

Use cases

One customer-onboarding block for every sales channel

Orders from the store, bookings and form sign-ups all need the same onboarding. Build it once, call it from three parents.

WooCommerce new order → Call Sub-Workflow (email, name) → Sub-workflow: FluentCRM contact → Send Template Email → Return Response (contact_id)

A shared lead-scoring service

An AI Agent scores leads the same way wherever they come from. The parent decides what to do with the score.

Form submission → Call Sub-Workflow (company, message) → Sub-workflow: AI Agent (score 1–10) → Return Response (score) → back in parent: Branch (score Greater than 7) → HubSpot Create Deal

A standard client report for agencies

Each client has its own scheduled workflow with its own settings, but the report itself is built in one sub-workflow, so a design change applies to every client.

Schedule (monthly, per client) → Call Sub-Workflow (client_id, site_url) → Sub-workflow: API requests → Generate PDF from Template → Send Email → Return Response (sent)

A single place to raise support escalations

Failed payments, angry reviews and urgent tickets all escalate the same way: a Slack alert and a ticket. One sub-workflow keeps the format consistent.

Any trigger → Call Sub-Workflow (reason, customer_email) → Sub-workflow: Slack Send Channel Message → Fluent Support ticket → Return Response (ticket_id)

Reusable data clean-up

Internal ops normalise names, phone numbers and dates in many workflows. A formatter sub-workflow returns clean values that every parent can map.

Webhook → Call Sub-Workflow (raw fields) → Sub-workflow: Text Formatter → Date/Time Formatter → Return Response (clean fields) → back in parent: Google Sheets Add New Row

SaaS account provisioning

New accounts arrive from Stripe and from manual sign-ups. One provisioning sub-workflow creates the WordPress user and records the account.

Stripe New Customer → Call Sub-Workflow (email, plan) → Sub-workflow: WordPress Create User if Not Exists → WP Tables New Record → Return Response (user_id)

Tips and gotchas

  • Keep sub-workflows that return data short-running. The parent runs the sub-workflow within its own run and reads the Return Response when it finishes. If the sub-workflow pauses on a Delay of a minute or more, waits for an approval or runs a Batch Iterator, its Return Response hasn’t happened yet when the parent moves on, so the parent gets no response.
  • Name your parameters well. The keys you pass become the trigger fields in the sub-workflow and the keys you return become fields in the parent. Clear names make both sides easier to map.
  • Re-capture after changing parameters. If you add a parameter in the parent, run the capture again so the new field shows up in the sub-workflow’s tag picker.
  • Keep it switched on. A sub-workflow must be on to be called, even though it never fires on its own.
  • Debug each side. Open the parent’s run for the Call Sub-Workflow input and output, and the sub-workflow’s own run for its steps.

Related features

  • Multi-trigger workflows: when several events share one workflow, start it from several triggers instead.
  • Variables: share values, not steps, across workflows.
  • Task History: follow a parent run and its sub-workflow runs.

FAQ

How do I pass data to a sub-workflow?

Add key and value pairs under Parameters to Pass in the Call Sub-Workflow step. Each key becomes a field of the Start Sub-Workflow trigger, which the sub-workflow’s steps can map.

How does a sub-workflow send data back?

With a Return Response step as its last step. The keys under Response Data appear as outputs of the Call Sub-Workflow step in the parent.

Can a sub-workflow call another sub-workflow?

Yes, as long as the chain never loops back to a workflow that is already running in it. FlowMattic detects that circular dependency and stops the call with an error.

Why doesn’t my workflow appear in Select Sub-Workflow?

Only workflows whose trigger is Start Sub-Workflow are listed. Set that trigger, save the workflow, and it appears with the SUB badge.

Sub-workflows are included in every FlowMattic plan, with unlimited workflows and runs on your own server. Try FlowMattic on a live demo site and turn your most repeated steps into a reusable sub-workflow.

More from the blog