Smart iteration for routing

Hi all,

I am building an automation flow to find contact persons at companies and add the result to airtable. The way the contact person is found is via API call with payload ‘company’ and ‘job title’. The base flow is easy, however the complicaiton is resulting from

  • I need 2 contact persons per company
  • At not every company, the relevant job title is findable and I then need to search for the next job title down the chain (there are 4 levels)

This means, that I might find 1 contact person for job title 1 and then need to find the second with job title 2 (and if that fails with job title 3, and then 4). As a result, I have build a ‘tree’ that splits of for the different scenarios, but it is overly complicated and if anything changes in the airtable or so I need to update it in many different places (very error prone).

The good thing is, the ‘database’ of job titles is static, i.e. I first search for a certain set of titles, then the next set if the first didnt give any results (or only 1) and then the next etc.

My thought is that there must be a way to have a storage of the job titles and then iterate through them until both contact persons are found. Maybe splitting the flow for contact person 1 and contact person 2, but somehow ensuring they are not the same.

I dont know though how to build a flow that runs through the options of the job title hierarchy sequentially and only if either both or only one of the two contact person slots is still empty - any ideas? I am new to make, so ‘easy to understand’ responses would be much appreciated :smiley:

Here the current ‘tree’