Combine Multiple Items into one Item. from a list pass only Items that match condition

Hi all, been a while since I wasn’t able to figure out something myself which is good. but I have 2 main request that I need help with. Combine I have a work flow that sends a request to a LLM but its a sheet and it send the requests as individual request which give a server receive too much request error is their a was from me to combine all items to one request.

also I have another issue where I have a array and I want to return only the items that match my condition and discard the rest.

Hi @0ne, I am sorry you’re having trouble.

its a sheet and it send the requests as individual request which give a server receive too much request error is their a was from me to combine all items to one request.

n8n’s HTTP Request would send a single request for every single item it receives. It might be possible to combine multiple items into a single item, but this will depend on how exactly your items look like and what your API accepts.

Perhaps you can share an example of the JSON data you currently have and what you would like to see instead?

Alternatively, if you simply want to reduce the amount of requests sent at once you can use the Batching options offered by this node (available through the Add Option button):

image

The above example would send 50 requests every 1000 milliseconds, but you can adjust this as needed of course.

also I have another issue where I have a array and I want to return only the items that match my condition and discard the rest.

Here you probably want to use the Item Lists node to split out the items in your array, then use the Filter or If node to keep only the items you need.

1 Like

Sorry for the late reply. its more like Im looking for a way to clean data. new example I want to remove “Here is a draft introductory email:” and “[Your name]
[Your company]
[Contact information]” from response from anthropic but I cant find a easy way to do it with the nodes you recommend above { "meta": { "instanceId": "99441d276deba5f24c7b2fdca074c5ef6140bccbdb7d6fefc01c5987f0fd2f39" }, "nodes": [ { "parameters": { "method": "POST", "url": "https://api.anthropic.com/v1/complete", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json" }, { "name": "anthropic-version", "value": "2023-06-01" }, { "name": "x-api-key", "value": "API KEy" } ] }, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "model", "value": "claude-2" }, { "name": "prompt", "value": "=Human: {{ $json['Business Card info '] }}\"} \\n\\nAssistant:" }, { "name": "max_tokens_to_sample", "value": 10250 } ] }, "options": {} }, "id": "8665df3f-faeb-4a8f-a337-77362c659a4a", "name": "Anthrop\\c", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1260, 420 ] } ], "connections": {} }

A replace function would be great like a replace node replace matching string with nothing or preselected text :thinking: :+1:

A replace function would be great like a replace node replace matching string with nothing or preselected text :thinking: :+1:

Hi @0ne, in theory you can use the .replace() function inside your n8n expressions, but it’s not clear to me what exactly you’re looking to replace. Your previous post contains a HTTP Request node which I will not be able to execute.

Instead of the node itself, can you share an example of the JSON data you currently have and the JSON data you would like to see instead? This should help me provide an example for your data transformation.

Here a screenshot want to remove those text so I send directly in a way preformat message before sending

Hi @0ne, if you want to remove specific text from your completion field, the .replace() function from my last post should be the exactly right one for you. Here’s a quick example workflow showing the idea:

It will replace Lorem ipsum... with an empty string. Simply update the expression on the “Remove text” node as needed to replace your particular text snippet instead. You can remove or add additional .replace() functions as needed as well :slight_smile:

thank you let me give that a try

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