subflow-plus

Sub-workflow inputs with Required, Default, Type and Description, checked before the sub-workflow runs

Documentation

n8n-nodes-subflow-plus

Sub-workflow inputs that can be required, with a default, a type and a description, checked before the sub-workflow does anything.

The native "When Executed by Another Workflow" trigger only has a name and a type for each input: none can be required, and the caller can leave any of them empty. This package adds two nodes:

  • Subflow Inputs: goes in the sub-workflow, right after its trigger. It declares the inputs and checks every item: a required input missing stops the sub-workflow with a clear error, a value of the wrong type too, and an empty optional input gets its default.
  • Execute Subflow Plus: goes in the workflow that calls. It reads the inputs of the Subflow Inputs node and shows them, the required ones marked as mandatory, before you run anything.
Caller:        … → Execute Subflow Plus (Workflow: Charge customer)
                       customerId *   {{ $json.id }}
                       total *        {{ $json.amount }}
                       method         boleto

Sub-workflow:  When Executed by Another Workflow (Accept All Data)
                 → Subflow Inputs → …

Install

In n8n, go to Settings → Community Nodes → Install and enter n8n-nodes-subflow-plus.

Subflow Inputs

  1. In the sub-workflow, set When Executed by Another Workflow to Input Data Mode: Accept All Data.
  2. Put Subflow Inputs right after it and add the inputs.
Field
Name The name of the input, as the caller sends it
Type String, Number, Boolean, Array, Object, Options (one of a list) or Allow Any Type
Allowed Values For Options: the values allowed, separated by commas. The caller gets a dropdown
Required The sub-workflow stops with an error when the input is missing or empty (empty text counts as empty)
Default For an optional input: used when it is missing or empty. Typed as text: 10, true, ["a"], {"a": 1}
Description Shown in the error when a required input is missing

Text that reads as the type is converted: "12" or "12,5" for a Number, "true", "sim", "1" for a Boolean, a JSON text for an Array or an Object. Anything else is an error, for example Input "total" should be a number, got "abc".

Option
When an Input Is Invalid Stop With an Error (default): the sub-workflow fails and the caller gets the error. Send to the Invalid Output: the item goes on through a second output with an errors list, to handle it yourself
Keep Other Fields Off (default): only the declared inputs come out. On: the other fields of the item are kept too

It works with the native Execute Workflow too: the checks run in the sub-workflow either way.

Execute Subflow Plus

Choose the Workflow. The Workflow Inputs come from its Subflow Inputs node: the required ones are marked as mandatory and can't be removed, an Options input is a dropdown. Map each one with a value or an expression.

  • A required input left empty stops this node, before the sub-workflow starts.
  • Attempt to Convert Types converts text that reads as the type, as in the native node.
  • Mode: run once with all items, or once for each item. Wait for Sub-Workflow Completion in Options.
  • A sub-workflow without Subflow Inputs shows the inputs of its native trigger, none of them required.

If you change the inputs of the sub-workflow, use Refresh Input List in the menu of Workflow Inputs.

Limits

  • An active workflow can only call a sub-workflow that is published (active), like with the native Execute Workflow.
  • n8n always starts a sub-workflow at its native trigger: Subflow Inputs goes after it, it can't replace it.

License

MIT

Discussion