Series 01 Episode 08 🚀 n8n Knowledge for Beginners 🚀

Illustration of several n8n workflows calling one shared module

The same piece of logic, e.g. cleaning up an email address, gets copied into yet another workflow. You change the rule and have to fix it everywhere. There is a better way: a sub-workflow.

Four things to get right:

  1. Sub-workflow: a regular workflow that starts with an Execute Workflow Trigger node. It does one thing and returns the result.
  2. Execute Workflow: a node in the main workflow that runs the sub-workflow. You choose which workflow to call and pass it data.
  3. Input data: in the sub-workflow's trigger you set Input data mode, e.g. Define using fields below. The workflow then receives only the fields it expects, not everything.
  4. Result: the output of the sub-workflow's last node comes back to the main workflow. You keep working with it as usual, e.g. {{ $json.email }}.

Watch out for:

  • Changing the input fields in a sub-workflow breaks every workflow that calls it. Give it a clear name and change it carefully.
  • Run once for each item runs the sub-workflow separately for every item. With a large list that means many executions. If one call is enough, choose Run once with all items.
  • An error in a sub-workflow usually stops the main workflow too. Handle it the way we did in episode 06.

Rule of thumb: when the same logic shows up a second time, move it into a sub-workflow.

Upcoming meetups and workshops are listed in the Events section.

← Back to the knowledge baseShare on LinkedIn (opens in a new tab)