Calling another workflow

Hello!

I’m running n8n on docker (from a Synology NAS).
First of all, thank you so much for your hard work. I’m really enjoying using n8n, it gave me a lot of ideas to put in motion. I’m not much of a devoloper, but now this makes it easier to accomplish what I want to do.

To simplify:
I have a workflow, that should check if a user exists in a database. (Let’s call this Workflow U)
I have another workflow, that should register a record in a database IF the user exists. (Let’s call this Workflow A). This is triggered by a webhook.

This should work like… Workflow A -> (Workflow U) -> MySQL

Is this possible?
How should I setup the Workflow B? It says I can’t activate unless I have a trigger.
Can I send data to Workflow U and get it back?

Thank you for your help.

Welcome to the community @ZXS! Great to hear that you enjoy n8n!

About your question. Yes you can one workflow from another with the “Execute Workflow” node:

Guess what you describe now as Workflow B is this: Workflow A -> (Workflow U) -> MySQL

How should I setup the Workflow B? It says I can’t activate unless I have a trigger.
Yes, that can not be activated as the workflow itself does not have a trigger. You would have to “move” the trigger (in thise case the Webhook-Node) from Workflow A to workflow B.

Can I send data to Workflow U and get it back?
Yes, that is how the “Execute Workflow” node behaves by default.

I hope that helps!

1 Like

Hey @jan, thank you so much :slight_smile:

The “Workflow B” was meant to be “Workflow U”, in my op. Sorry about the confusion.

I’m not sure I understand “moving” the Webhook. The entry Workflow (in my case, i referenced it as Workflow A) also needs a webhook-node. Should I set both with webhook-nodes?

Thank you for your time!

I think I figured it out, but now I get an error on my first “Execute Workflow” (when requesting “Workflow U”):

ERROR: No credentials of type "mySql" exist.

Workflow U, uses a MySQL-node. It has the correct credentials set up, it can run on its own.

Strange. Will check it out.

Yes sorry. There was a bug. Did just fix it and will release with the next version. Will update here once released.

1 Like

Awesome, can’t wait :slight_smile:

Got released with [email protected]

Hi!

I can confirm this is now working! :smiley:

However, I haven’t figured out something. To activate the worflow, we need to have a trigger. In my case, I used a webhook trigger. But when we use the “Execute Workflow”, the starting point is not the trigger, but the Start-node (which makes sense, sure). Why force a workflow to have a trigger?

In any case, I was having this config:


This allowd the wf to be called internally or via webhook. However, this was not working, because the mysql-node needs to grab something from the previous node. It was specifically getting from the Webhook-node like so: {{$node["Webhook"].json["headers"]["yadayada"]}}, but of course, if it was called internally, the previous node is the Start-node.

Is there a way to grab the “previous”-node? If not, to make this available to both webhook trigger and via “Execute Workflow”-node, do I need an node inbetween to test where the data comes from?

For now, I just removed the link between the webhook and the mysql-node, and changed the variable to use the start-node data, as I don’t need this specific node to use webhook, but I’m interested in this as I might have a use case for it.

Thank you so much for your help!

I made it work with simply $json["headers"][...]. No other nodes in the middle.

Is this a good approach?

Yes exactly. There are two ways to solve it:

  1. Using directly $json which uses the input data
  2. Simply creating another node before the “Get User” one (like a NoOp) node which simply does not do anything and then reference the values from that one.