Parallel informations extract in n8n

Hi everyone,

What is the error message (if any)?

My goal is to generete images based on actual pictures I have on a folder on my computer (local folder). I use a text file in my folder to retrieve the prompt that i need to use, and the images i need to modify. But when I run my workflow, I only end up with my images, and not my prompt, or the opposite depending on how i merge both.

This should be a simple problems but I am not used to this feature of n8n compared to other automation tools such as knime for exemple. Would you have an idea on how I can merge these two informations to set up my gemini nano banana node ?

Please share your workflow

This is my workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

{

“nodes”: [

{

“parameters”: {

“conditions”: {

“options”: {

“caseSensitive”: true,

“leftValue”: “”,

“typeValidation”: “strict”,

“version”: 3

},

“conditions”: [

{

“id”: “5cfe14b7-c8aa-4328-91b2-bea4c548a20e”,

“leftValue”: “={{ $json.fileName }}”,

“rightValue”: “^#.*\\.png$”,

“operator”: {

“type”: “string”,

“operation”: “regex”

}

}

],

“combinator”: “and”

},

“options”: {}

},

“type”: “n8n-nodes-base.filter”,

“typeVersion”: 2.3,

“position”: [

560,

208

],

“id”: “1f3415ae-9983-466a-bdac-27e53b450056”,

“name”: “Filtre les images a utiliser”

},

{

“parameters”: {

“operation”: “text”,

“destinationKey”: “prompt”,

“options”: {}

},

“type”: “n8n-nodes-base.extractFromFile”,

“typeVersion”: 1.1,

“position”: [

832,

464

],

“id”: “fb72575e-1ac6-4ad3-90c7-ad715725ee4a”,

“name”: “Récupère le contenu du .txt”

},

{

“parameters”: {

“conditions”: {

“options”: {

“caseSensitive”: true,

“leftValue”: “”,

“typeValidation”: “strict”,

“version”: 3

},

“conditions”: [

{

“id”: “5cfe14b7-c8aa-4328-91b2-bea4c548a20e”,

“leftValue”: “={{ $json.fileName }}”,

“rightValue”: “_prompt_IA.txt”,

“operator”: {

“type”: “string”,

“operation”: “equals”

}

}

],

“combinator”: “and”

},

“options”: {}

},

“type”: “n8n-nodes-base.filter”,

“typeVersion”: 2.3,

“position”: [

560,

464

],

“id”: “53acf130-0386-4b4e-a4c2-81f51fe4eef3”,

“name”: “Récupère le script pour les images”

},

{

“parameters”: {

“fileSelector”: “=/sources/Poses/{{ $json.fileName }}”,

“options”: {}

},

“type”: “n8n-nodes-base.readWriteFile”,

“typeVersion”: 1.1,

“position”: [

832,

208

],

“id”: “d4d36e1a-8339-4053-81ac-6297842c7ab2”,

“name”: “Lis chaque image présente”

},

{

“parameters”: {

“resource”: “image”,

“operation”: “edit”,

“modelId”: {

“__rl”: true,

“value”: “models/gemini-2.5-flash-image”,

“mode”: “list”,

“cachedResultName”: “models/gemini-2.5-flash-image (Nano Banana)”

},

“prompt”: “={{ $json.prompt }}”,

“images”: {

“values”: [

{}

]

},

“options”: {}

},

“type”: “@n8n/n8n-nodes-langchain.googleGemini”,

“typeVersion”: 1.1,

“position”: [

1360,

336

],

“id”: “51bc9cff-e9c9-49ec-920f-810381f5b190”,

“name”: “Edit an image”,

“alwaysOutputData”: true,

“credentials”: {

“googlePalmApi”: {

“id”: “gsddsg”,

“name”: “XaX”

}

}

},

{

“parameters”: {

“fileSelector”: “/sources/Poses/*”,

“options”: {}

},

“type”: “n8n-nodes-base.readWriteFile”,

“typeVersion”: 1.1,

“position”: [

64,

336

],

“id”: “ac917252-31d6-4c9a-a5e4-b57e996c96da”,

“name”: “Récupère les fichiers du dossier”

},

{

“parameters”: {},

“type”: “n8n-nodes-base.merge”,

“typeVersion”: 3.2,

“position”: [

1136,

336

],

“id”: “53eb35db-365c-42ee-af08-84d9831d86a5”,

“name”: “Merge”

}

],

“connections”: {

“Filtre les images a utiliser”: {

“main”: [

[

{

“node”: “Lis chaque image présente”,

“type”: “main”,

“index”: 0

}

]

]

},

“Récupère le contenu du .txt”: {

“main”: [

[

{

“node”: “Merge”,

“type”: “main”,

“index”: 1

}

]

]

},

“Récupère le script pour les images”: {

“main”: [

[

{

“node”: “Récupère le contenu du .txt”,

“type”: “main”,

“index”: 0

}

]

]

},

“Lis chaque image présente”: {

“main”: [

[

{

“node”: “Merge”,

“type”: “main”,

“index”: 0

}

]

]

},

“Edit an image”: {

“main”: [

]

},

“Récupère les fichiers du dossier”: {

“main”: [

[

{

“node”: “Filtre les images a utiliser”,

“type”: “main”,

“index”: 0

},

{

“node”: “Récupère le script pour les images”,

“type”: “main”,

“index”: 0

}

]

]

},

“Merge”: {

“main”: [

[

{

“node”: “Edit an image”,

“type”: “main”,

“index”: 0

}

]

]

}

},

“pinData”: {},

“meta”: {

“templateCredsSetupCompleted”: true,

“instanceId”: “wvfvwdvfwdvw”

}

}

Share the output returned by the last node

Depending on how I connect the two informations (images and prompt), I often end up like in this workflow with no data from the txt file, that I need in my gemini node.

Information on your n8n setup

I run npm on a local server, using the latest version on docker hub.

Thank you.

1 Like

Hi @Kikodiver ,

Tip: Insert your workflow by clicking ‘</>’ and pasting in the workflow’s code!

Hi @Kikodiver

Your issue is not related to Gemini itself but to how n8n handles parallel data streams.

In n8n, each item is processed independently. Your images and your prompt file are coming in as separate items, so when you merge them, you either get the image item or the text item, not both, depending on the merge mode and execution order.

What is happening now

  • The image branch outputs one item per image with binary data.

  • The text file branch outputs a separate item containing the prompt.

  • The Merge node is not aligning them into a single item, so $json.prompt is missing when the image item reaches Gemini.

How to fix it
The simplest approach is:

  1. Read and extract the prompt first.

  2. Store the prompt as a fixed field.

  3. Attach that same prompt to every image item before sending to Gemini.

Concrete solution

  • Read the txt file and extract the prompt.

  • Use a Set node after extracting the text to store it as prompt.

  • Then use a Merge node in Merge by Position or Merge by Index, where:

    • Input 1 is the images list

    • Input 2 is the single prompt item

  • This way, the prompt is duplicated onto each image item.

Alternative and often cleaner:

  • Use a Function or Set node after the image reader.

  • Reference the prompt directly using an expression like:
    {{$items("Récupère le contenu du .txt")[0].json.prompt}}
    This avoids Merge entirely.

Once each image item contains both binary.data and json.prompt, the Gemini image edit node will work as expected.

You are very close. This is a common n8n data model pitfall when coming from tools like KNIME.

Hope this helps