Redirect server with n8n - how to pass through arbitrary query parameters?

Hi,

I am setting up a GET webhook in n8n that needs to check the latest value of a redirect_url (stored in a gSheet) before GET-http calling that redirect_url.

Passing one GET query parameter from the initial webhook to the redirect_url is OK… but I would need to have a flexible and robust way to do that, i.e. different webhook calls can include or not this or that query parameter…

Thanks a lot for your help,
Cédric

Hi @Udexia_Ridl, I am not sure I fully understand the question.

Do you want to use a webhook node in n8n and redirect users opening that webhook URL based on a query parameter? This could be done with a workflow like so:

This example uses a location header for the redirect using the redirect_url query parameter. Of course you can include any checks you like between the Webhook and Respond to Webhook node.

2 Likes

Not really, sorry for not being clear. I’ll give more details.

Context: I have a Bubble.io webapp. When users interact with it, depending on what they do, an API call is done to a Google App Script webapp-endpoint passing parameters - the “backend” is really done in Google App Script.

Problem: every time I change something in my Google App Script, I need to deploy and I get another webhook URL - which I then need to copy paste several times in Bubble.io.

What I’d like to do: be able to deploy my GAS webapp and limit the number of copy/pastes I need to do.

My proposed solution: when I deploy my GAS webapp, I copy the new webhook URL and paste it in a given cell of the associated Google Sheets. Bubble.io wouldn’t call directly the GAS webhook anymore, but a n8n workflow. This workflow would get the new GAS webhook’s URL from google sheet and call it, passing through all the GET parameters that need to be passed to GAS webhook (that are initially known by Bubble.io and passed today directly to GAS, tomorrow to n8n THEN to GAS).

Status: I know how to create a webhook in n8n, how to get the gSheet cell’s value (i.e. the up-to-date GAS webhook URL), but not how to propagate the query parameters from the n8n webhook to the http request node. More precisely, what do I need to do in the “function” node and and the subsequent “http request” node to get then pass all the query parameters from the n8n initial webhook?

Hope this clarifies - please let me know if not. Thanks for your help!

Okay, so I think we can work this out. You wouldn’t need the Function node to read a query parameter, a simple expression will do. In fact the Function node causes another problem here as it will make your HTTP Request node run at least twice which is probably not what you have in mind.

This is because (most) n8n nodes would run once for each item they receive. In your workflow, the HTTP Request node gets items from your Google Sheet and from your Function node, so would run twice or more (if your sheet has more than one item).

So my first suggestion would be to remove the Function node.

Then, execute your workflow manually and send a dummy request to your webhook test URL including the query parameter you want to use (you could simply open the test URL in your browser to do so). You should now have access to some example data to work with right in n8n. In your function node you can now simply add a new query parameter using an expression like so:

image

In the expression editor you can now simply click your way down to the query parameter you want to use in your HTTP Request node:

Got it for the 2 executions, thanks.

It’s not a single parameter that needs to be passed through the workflow, but many, and I don’t even know them all today. In the future there can be new parameters sent to the webhook, and I’d like ideally to have something generic enough to just pass any parameter that is sent to n8b through to GAS, hence the formula node I was imagining, to programmatically extract all parameters from the initial call and push them to the http request node.

Thanks again for your help

No rush at all but just to be sure I was being clear enough: my problem is not solved yet :wink:
I cannot assign one by one the paremeters because they can vary from one webhook call to the other, and new use case can emerge in the future - that will require new parameters…
Thanks for your help

I’m not entirely sure that this is what you are needing, but I believe that you can add multiple variables to a query template that would auto populate. Unless there are variations in the order, in which case maybe some If/Then nodes could route them to the correct format.