Help with workflow: Switching off of array data

Hey all,
I am making a workflow to take Hubspot contacts, verify their phone type (mobile, landline, voip) with the twilio lookup api and add them to a marketing list if they have a mobile number. The issue i’m running into is checking which lists each contact are in.

The list data is returned thusly:

[
  {
    "static-list-id": 3,
    "internal-list-id": 3,
    "timestamp": 1627415819322,
    "vid": 19769,
    "is-member": true
  },
  {
    "static-list-id": 8,
    "internal-list-id": 10,
    "timestamp": 1633026991979,
    "vid": 19769,
    "is-member": true
  }
]

I have a switch seeing if that array contains the list ID’s im looking for, but it isn’t working for all contacts if they are in a lower numbered list. Is there a way to do this with the switch or am I going to need to preprocess the data with a function?

Full workflow below:

Thanks for reading

If I understood correctly, you could probably get it to work with either the Item Lists node or the Function Node. Check the example below:

Hey Ricardo,
I think that example might help, but what I am trying to do is check all of the memberships and, if they are a member of list 8 or 9, not run my verification code. Its looking like I need to write a function to accomplish this. Thanks for your help!

Ahh yes, I just do not have the Twilio credentials to put together the whole workflow.

Can’t you use an IF node? if internal-list-id equals 8 or equals 9.

I tried that, but list-membership is an array of 2 json objects. It’s seemingly only evaluating the first object. So if a contact is in multiple groups, it only checks the first one.

Yes, because you are only checking the first item of the array. That is why I used the Item list node; to move the items to the main level. That way, you can evaluate all the items instead of only the first one.

Perhaps, the example below helps to understand what I mean.