Data driven workflow

Hi,

I have database table updated with list of api calls. Is it possible to create workflow based on entries from table. There could be 30 to 40 calls with some calls depending on others.

First part YES, second part YES but would get hard.

You can have columns like: URL, method, query-parameters, ...
Then you read that table and plug it directly into an HTTP Request node which uses them via an expression and you are done.

But if it is then about the calls being dependent on each other it will get complicated. Not sure how something like that could be build best without spending a lot of time on it now. You could for sure write custom code in a Function-Node which generates new n8n workflows on the fly and executes them with an Execute Workflow node. Maybe there is also a way with the correct data-design to build a workflow with multiple HTTP Request nodes chained.

Can you provide sample of function node generating workflow on the fly?

No sorry, that is sadly very custom and time-consuming and depends a lot on what exactly you want to do. But you can start by copy and pasting an example workflow in a text-editor. Then you know what you need as a result.

Here a question from a few days ago which explains how connections are defined in the n8n workflow JSON:

That should help.

Apart from that should it not be to hard if you are a programmer, but would for sure take some time. If you are not a programmer it is probably not the best idea trying to do that.

If I understand you correctly, what you are suggesting is to generate .json based on how editor generates json. I am a programmer and i probably could make it happen, how do i make .json as workflow on the fly?

Perfect! Yes exactly, that is what I am proposing.

You do that by:

  1. studying how the n8n-workflow JSON works (how nodes do get saved and how connections are made, therefor the linked topic above)
  2. generate a workflow in a Function Node
  3. return it as a property in the flow (under “json”, for example, called “workflow”)
  4. create an Execute Workflow Node which is set to “Source -> Parameter”
  5. under the parameter “Workflow JSON” reference that workflow via an expression