How to create a webhook triggered workflow with Wait on Form Submit and Respond to Webhook

Describe the problem/error/question

When I have a webhook trigger set to Respond to Webhook, with a Wait Node set to wait on form submission, I cannot manage to make it work. In this scenario, it forces the Wait Form to be also set to Respond to Webhook, and the webhook GET call never returns.

If I set the webhook trigger to respond with last node data, it doesn’t wait for the last node after the wait node, it returns immediately without the data sent on the form in wait node.

What is the error message (if any)?

When I trigger the webhook with a GET request, and after submitting the form on wait node, the request to the webhook never returns (it times out), and the form data appears on the browser that I did the form submission.

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.108.1
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: linux aarch64

Hey @Marcos_Junior :waving_hand:

I just looked at the workflow JSON you shared, and I think the issue is in the Wait node configuration. Having "responseMode": "responseNode" inside the Wait node is not a good idea for this scenario, because the original webhook request can’t be kept open while the workflow is paused. That’s why your webhook GET call never returns and times out. I recommend to let the Webhook Trigger respond immediately "responseMode": "lastNode", and then use the Wait node purely for form submission. After the form is submitted, you can continue the flow and, if needed, send the collected data back using a separate HTTP Request node instead of trying to respond to the original webhook.

Please let me know if this doesn’t resolve the issue. :victory_hand:

Hm, I’m not sure how I could achieve that from the perspective of the code that calls the initial webhook. If the initial webhook returns immediately, the calling code will proceed before having the result I collect from the form.

Is there a way to make another http call to query the very same execution later on - so I could in the calling code to pool for a result until it is ready?

Context: The calling code is a pure js code making a call using axios. My initial plan was to have this axios call to be blocked until either a form is submitted on this workflow, or errors with timeout.

Hey! You can’t have 2 triggers (Form, Webhook) in a single flow and have them both work in the same execution unfortunately.

I would recommend using a sub-workflow, as it will wait for the form and output the result to the main flow:

Fee free to mark as Solution if it helps

Interesting this idea made the main webhook to wait for the subworkflow to run. But then when I submit the form, the data does not come back to the main one. Not sure if it is a limitation or something I missed.

Hello @Marcos_Junior, how are you?

What you need is this:

:light_bulb: Double-click a node to see its settings, or paste this workflow’s code into n8n to import it

To explain the concept, before the wait, you must perform a redirect with the variable {{ $execution.resumeFormUrl }}.

This will display the form you created in the wait.

I hope this is what you need. If so, please mark this answer as the solution.

1 Like

I don’t think that applies to my case. The calling code calls the webhook and expects a json result, there is no browser to display a form. The form will be displayed on a mobile device via a push notification.

Exactly, just send the push notification with the event so that when the user opens the notification, they will be directed to the URL.

The example I demonstrated is due to not having an application available for push notifications.

Could you also post the sub-workflow so I can try and reproduce it?

Sure @krisn0x, see below:

Main:

Sub workflow:

@gabrielhmsantos I don’t really think that works in my case, as I have two separate devices interacting with this.

The first one is running the webhook call, like posting to https://n8ninstance/webhook/test. This webhook is supposed to push a notification to an android phone with the form and wait until this form completes. It is important to wait for the form completion because the one making the HTTP call needs to have the result synchronously.

It seems on your idea that this post to the webhook returns immediately before the user completes the form on mobile phone, which defeats the purpose.

But that’s exactly it, the respond to webhook that I set up you will replace with pushover.
For better understanding, it is the same flow that you created.

Here is the example (I created an account on Pushover to test)

I think you are misunderstanding the use case. Here is how it should go:

  1. Webhook trigger is triggered from a server
  2. It sends a message with the form to a user
  3. The user submits the form
  4. The flow should process the form and send the data to the server

In your flow, you are sending the form link back to the server by responding to the initial webhook trigger. It needs to go to the user instead.

@gabrielhmsantos I can see the result in the workflow, however the issue is the HTTP call that is made to the webhook to start the process. This call should wait for the form result, but it seems there is no way to do that on a workflow with a wait-form. It doesn’t wait, returns immediately, so the process that calls it can’t read what you type in the form field.

Welp, it’s a bug and the team won’t fix it until they do V2 of n8n as it’s very deep in the architecture and will require a lot of work.

I came up with a new solution. The sub workflow updates a DB (Sheets) with the execution id of the main flow + the code from the form. Then the main flow checks the same DB to pull the row with that execution id.

You will need to change nodes or values as I tested with my custom sheet. Let me know if you like that.

1 Like

@krisn0x Interesting idea. I guess I would need to check the sheet in a loop so that if user is quick with the form, it doesn’t need to wait the entire designated time?

Forgot to link the bug btw

While waiting for the form submission, everything is paused, so no need for changes there. Once the form is submitted, the sub-flow will finish, the main one will continue and will reach a short wait node I placed, just in case the Sheets nodes were slow or take time to update.

You could have an IF node and loop every 2 seconds or something, true, but you will also need to add a code node and count how many times you loop, so you can eventually stop the loop and continue. Otherwise if you just loop and the sheet never updates, the flow will never reach the end.

1 Like

@krisn0x Your solution works as I expected, I just made some slight changes to it but your overall idea works nicely. Thank you for your insights.

1 Like

Hi all, I had the same problem today while trying to modify a workflow that runs sub workflows in queue mode. I put a wait node with a webhook and the $execution.resumeUrl option.

It works very well when all that process is launched manually, but it fails when it becomes a subworkflow like this one :

So I will wait for the V2 of n8n !

In fact I see exactly my bug here : Wait Node Not Receiving Updated Data from Resume Webhook - Getting Original Parameters Instead