Workflow fork doesn't wait nor run all the way to the end

I have two problems I’m trying to understand:

I’m “forking” the workflow at a certain point in which they do two different things, but I get them together in the end for a tweet that needs both those inputs. However one path is faster than the other one and essentially it results in the tweet being incomplete. I’d probably need to implement some sort of “wait” node so that the tweet only triggers when both data points have arrived. Is this (Wait node in workflow [GOT CREATED]) the way to do it?

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "const waitTimeSeconds = 3;\n\nreturn new Promise((resolve) => {\n  setTimeout(() => {\n    resolve();\n  }, waitTimeSeconds * 1000);\n});\n\n"
      },
      "name": "Wait",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        802,
        416
      ]
    }
  ],
  "connections": {}
}

1.1: How many seconds can I delay it?
1.2 How would I attach an IF element to check if the data did not arrive in time and only continue to tweet if both elements are ready?

  1. the workflow does not seem to run all to the end - in my case after another fork, it does go towards the tweet, but not towards appending that data to a spreadsheet. What am I not considering?

Thank you, screenshot of situation is attached:

If you connect two input-connections to a node with only one input then the node will execute two times. Once for every input-connection.

What you want is to merge the branches first with a Merge-Node. It will then only proceed once data of both branches is available.

amazing @jan, I think that should fix both of my problems and I’ll move the sheet to the very end after the Twitter node.

Glad to hear! Have fun!

Hi Jan - does this work with two triggers?

Essentially trying to get a jotform trigger to occur at roughly the same time as a webhook (to link a jotform submission to an email thread). However, this isn’t working as expected - once one trigger occurs, the other will output as null and the flow will commence. Anyway to ensure that both occur before the merge is executed? Or otherwise an equivalent workflow?

1 Like

Hey @pb84, looks like @Jon already got back to you on Discord about this one.

You can’t require a single execution to be triggered by two separate triggers unfortunately, each execution would be independent from the other.

So you’d need to build the logic around this yourself if your specific use cases requires both a Jotform submission + a webhook to come in before doing something. For example if your forms come first just have one workflow that store the form responses in a database. Then, in your webhook flow query this database and merge the form data with your webhook data.

2 Likes

Thanks @MutedJam - makes sense

Any suggestions for storing and retrieving data from n8n in a database?

Depends on how much traffic and what kind of performance you’d expect.

I am by no means a database expert, but would probably go with PostgreSQL for such a job without further information. That’s mostly because I like the product and the n8n node for it though.

Unless you have very specific requirements everything starting with Google Sheets would probably do.