Retrieve the same strict output from a node several nodes later in a workflow

Hi everyone, I’m using the Brevo API to extract a list of very specific contacts from a list that I want to retrieve in full (+2000 contacts).

The problem with this API is that I have to call them all (contacts) in API, and filter them with n8n, to get rid of the contacts I don’t need, which are therefore not in the desired list. I can’t specify in the Brevo API call that I want such and such contacts in such and such a list.

Looking at their API, it is possible to extract all the contacts in a given list, BUT with a limit of 500 contacts per call, which is a real pain.

So I manage to retrieve all my contacts in a first call (+5000), but I have to call them back later in my workflow, which works but automatically crashes my workflow, because that’s +10000 items processed in a single workflow, which is obviously logical.

I wanted to ask you if it’s possible in Javascript, for example, to call back exactly the same output generated when I retrieve my 5k contacts in my Brevo call?

I’d love to share this workflow with you, but unfortunately it involves data from a CRM, and I don’t want to share it.

Hey @arthurcorre,

The workflow itself is just json and probably wouldn’t contain any returned CRM information so they are normally ok to share with very little risk (assuming you replace any hard coded credentials from http request nodes).

Ideally I would need a lot more about your workflow to be able to suggest how to handle it but the quick version is you can merge items from node executions using a code node and there are a few examples of how to do this but if you are working with that many items it would be best to use a sub workflow to loop over the items in smaller batches so that the memory is freed up.

Well, then I’ll try to describe it to you in more detail. The aim of my workflow is to determine the nearest installer of a building product, when a prospect requests a quote. The prospect gives his postcode, and we know the postcode of each of the installers.

So first we need to see if there are any known installers in the department, and if not, look in the departments bordering the postcode entered by the prospect.

In the first “IF” node, if the output is true, this means that there are one or more installers in the department. In the opposite case, if the output is false, this means that there are no installers in the prospect’s department, so we have to run the machine again, but for the departments around (bordering).

So I have to repeat the same operation (same call to Brevo) and reapply the same filters, because their API doesn’t allow you to do it any other way. What I’d like to get back is exactly the same output as my first filter node (with 2088 items).

Have you tried a merge node from the filter and item lists node? That would give you the items to use again.

You could also do both searches at once and work out the response from there.

1 Like

Works perfectly! Although I use this solution a lot, I hadn’t thought of it! Thanks a lot :slight_smile:

1 Like

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