Filtering a Google Contact Group so I can send emails

Hey there! Apologies for the basic newb’ish question. I’m trying to setup draft emails to contacts inside a specific Contact Group. My logic so far for the first 2 steps seems to work ok: run a List ‘Contact Groups’ module - filter to the required group via a Group ID filter through to ‘Get a Contact’ module. That all works then I thought I would add a ‘List my Contacts’ module and that would list just from the module before it but when it runs it just sees everything from Goggle Contacts not the desired targeted one Group…Any thoughts?

Hi @Jeff_Mackay,

Using just the built-in modules, you may need to use List My Contacts, get all of them, then use a filter to allow only those where Memberships.Contact Group Membership.Contact Group ID contains the name of the group from which you’re trying to retrieve contacts.

For example, after the List Contact Groups module, insert this filter condition:

Here is how the Memberships array is built in the List Contacts results:

So in the filter, we map all instances of contactGroupMembership into an array, then from that map all instances of contactGroupId into another array and the result is an array of group IDs to which that contact belongs.
In this example here I’ve got a contact in 4 different groups, including coworkers.

Coworkers was my target group, so in the filter the bundle (contact) only passes if the result of my nested map() functions (which again is the array of groups that contact belongs to), includes “coworkers”.

Just make sure the max results in the List Contacts module is high enough to retrieve all the contacts. I couldn’t figure out another way to get this done…

Hope that makes sense and hope it helps!

2 Likes

Thanks so much @Donald_Mitchell I’ll dive into that this week and see if I can get it to work!

It turns out @Donald_Mitchell I’m still a bit lost - I was a bit confused by your directions but I thought I was sort of following the logic in my own way - looking at the pics. I got as far as listing out the Group I wanted to target ‘MAKE’ and there’s 3 people in that group but I can’t figure how to then get as far draft emails to each…




Hi @Jeff_Mackay,
Looked into this some more and found a couple ways to handle it.

First, you can iterate the Member Resource Names, then using each result (people/c1232…), you can get the person’s details (Get a Contact), extract the email address, then move on to the next until you have them all using an Aggreagtor.

Another way, there’s a batchGet endpoint you can use to get a bunch of people in one shot. Here’s the setup…

Use Google Contacts Get a Contact Group, like you are, and the result is a collection, one item of which is an array of Member Resource Names
image

Follow that module with an Iterator so you can iterate those names
image

Run the scenario once so that the Iterator can figure out how the Member Resource Names array is structured.

Follow that with a Text Aggregator (Set your Source Module as the preceding Iterator module)

The result of this is a query string with the same parameter repeated for each of the names, something like this:

Using Google Contacts Make an API Call, configure it like this:
image

54. Text is is the output from the Text aggregator so replace that with your actual module’s output.
You don’t need to change anything else in the rest of this module.

Run your scenario to ensure you’re getting a good response, looks something like this:
image

The response is an array of collections.
Each collection has a person sub-collection.
If a person has an email address, an emailAddress array will appear within that person collection.

Following Google Contacts Make an API call, add an Iterator and iterate the responses array
image

Here is another good time to run the scenario so the iterator can get an idea of what the responses array looks like.

Add an Array Aggregator (the preceding Iterator is the source) and aggregate “person” from the Iterator module - person is the Collection from each of the collections from responses.

Between the Iterator and Array Aggregator, add a filter that only aggregates is the emailAddresses array exists.
image

The result is an array of collections again, but this time only those person where they had an emailAddresses array, which is my case was only 3 out of the 11 contacts.
image

Finally, need to manipulate that output array a little bit to get all the email addresses out of it.
image

We use map() to get all the emailAddresses arrays from each of the collections in the parent “Array”.
We then flatten those to bring the collections under EmailAddresses to top level, meaning now we have an array of emailAddresses arrays, which is now mappable.
So finally we use map() again, using “value” as the key.
The result is an array of email addresses.

I can post a blueprint a little later on if you want…

Edit: Adding blueprint
GetGoogleContactEmailAddresses.json (14.8 KB)

2 Likes

Thank you so much @Donald_Mitchell !! Very thorough indeed - ok so I started down the road of the 2nd option and lost of way towards the end but I’ve now tried a variation on your first suggestion and I’m good with that - again thanks so much for taking time on this much appreciated!!

3 Likes