Storing single value from JSON to use in node later on

Hey community,
I’m pretty new to N8N, but so far I’m super fascinated and happy with what I can build with only limited coding skills.

I have just run into my first actual problem building a “translator” workflow taking data from a form to push it to the DeepL API that I could really need help with.

The text to be translated is received via the Webhook node in the body of the API. It’s an array object consisting of “label” as key for the field of the text to be translated and “input” for the actual text to be translated. Additionally, I am passing parameters for the source language and for the target language.

So, naturally, my second node is the Item List node to split out the body of the webook into the single items to get a list of “label” (e.g. Main Image Headline 1) and its corresponding “input” text to be translated.

My third node then would be the DeepL API. It only requires the string to be translated (easy, just taking the input from the previous node under “input” to iterate through it), but also the target language and optionally the source language.

Now here’s the catch: I want to access the single value in the Webhook query parameters for source language and target language, but this only applies for the first item (naturally, since the following ones are undefined).

My question, then, is how can I accessa single value from a node (Webhook first and only item in query and then take sLang for source language and tLang for target language) to be passed to the DeepL node ALWAYS using this single only value that was set once for each iteration (so not trying to find corresponding values for each iteration because they are, of course, undefined)?

Any help would be much appreciated. Thank you guys & girls in advance! <3

Hey @ErikR, welcome to the community. Super happy to hear that n8n brings value to you. Would you mind copying your wofklow and pasting it in here? That makes it much easier to help you.

Hey @Niklas_Hatje,
certainly!

Here’s the workflow:

And, additionally, here’s a sample output of the webhook node:

[
{
"headers":
{
"host":
,
"x-forwarded-scheme":
"https",
"x-forwarded-proto":
"https",
"x-forwarded-for":
,
"x-real-ip":
,
"connection":
"close",
"content-length":
"1454",
"accept-encoding":
"gzip",
"user-agent":
"ReactorNetty/1.1.1",
"accept":
"*/*",
"content-type":
"application/json",
"authorization":
"Basic YWRtaW46ZEdxM0RmY2ZpQk45TlNMM01YUUM="
},
"params":
{
},
"query":
{
"sLang":
"DE",
"tLang":
"FR",
"sku":
""
},
"body":
[
{
"input":
"Test Headline",
"label":
"Image 2 Headline"
},
{
"input":
"Test Body",
"label":
"Image 2 Body"
},
{
"input":
"",
"label":
"Image 3 Headline"
},
{
"input":
"",
"label":
"Image 3 Body"
},
{
"input":
"",
"label":
"Image 4 Headline"
},
{
"input":
"",
"label":
"Image 4 Body"
},
{
"input":
"",
"label":
"Image 5 Headline"
},
{
"input":
"",
"label":
"Image 5 Body"
},
{
"input":
"",
"label":
"Image 6 Headline"
},
{
"input":
"",
"label":
"Image 6 Body"
},
{
"input":
"",
"label":
"Image 7 Headline"
},
{
"input":
"",
"label":
"Image 7 Body"
},
{
"input":
"",
"label":
"Image 8 Headline"
},
{
"input":
"",
"label":
"Image 8 Body"
},
{
"input":
"",
"label":
"Title"
},
{
"input":
"",
"label":
"Bullet 1"
},
{
"input":
"",
"label":
"Bullet 2"
},
{
"input":
"",
"label":
"Bullet 3"
},
{
"input":
"",
"label":
"Bullet 4"
},
{
"input":
"",
"label":
"Bullet 5"
},
{
"input":
"",
"label":
"Image 1 Headline"
},
{
"input":
"",
"label":
"Image 1 Body"
},
{
"input":
"",
"label":
"Image 2 Headline"
},
{
"input":
"",
"label":
"Image 2 Body"
},
{
"input":
"",
"label":
"Image 3 Headline"
},
{
"input":
"",
"label":
"Image 3 Body"
},
{
"input":
"",
"label":
"Image 4 Headline"
},
{
"input":
"",
"label":
"Image 4 Body"
},
{
"input":
"",
"label":
"Image 5 Headline"
},
{
"input":
"",
"label":
"Image 5 Body"
},
{
"input":
"",
"label":
"Question 1"
},
{
"input":
"",
"label":
"Answer 1"
},
{
"input":
"",
"label":
"Question 2"
},
{
"input":
"",
"label":
"Answer 2"
},
{
"input":
"",
"label":
"Question 3"
},
{
"input":
"",
"label":
"Answer 3"
},
{
"input":
"",
"label":
"Question 4"
},
{
"input":
"",
"label":
"Answer 4"
},
{
"input":
"",
"label":
"Question 5"
},
{
"input":
"",
"label":
"Answer 5"
}
]
}
]

As mentioned, the DeepL node goes through the JSON for the “query.tLang” parameters, but, of course, there’s only one in there. I want it to use the same exact value for every iteration of the item list.

Hi Erik,

I believe this should work (I pinned your sample data in the webhook to test so you need to unpin it to run with actual webhooks).

1 Like

Hi @romain-n8n,
thanks a lot for your help - this worked! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.