# Filtering a Google Contact Group so I can send emails

**URL:** <https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250>\
**Category:** Beginner Questions\
**Tags:** mapping, connections\
**Created:** [March 2, 2024, 1:25am UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250 "2024-03-02T01:25:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Mackay](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jeff\_Mackay](https://community.make.com/u/Jeff_Mackay)\
**Post date:** [March 2, 2024, 1:25am UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/1 "2024-03-02T01:25:16Z")

</div>

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?

 ![Screenshot 2024-03-02 at 12.06.57 pm](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/6/2696f692a09ca442f3ef791afceda01c98c388d1.png)

---

<div class="post-metadata">

**Author:** ![Donald\_Mitchell](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/donald_mitchell/32/8749_2.png) [@Donald\_Mitchell](https://community.make.com/u/Donald_Mitchell)\
**Post date:** [March 3, 2024, 7:55am UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/2 "2024-03-03T07:55:58Z")

</div>

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:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/e/e/eeb5696409cc1157cd17dd6e665317285fcb036d.png)

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

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/5/a5ab8f3630e402440404598d139d6756182f9334.png)

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!

---

<div class="post-metadata">

**Author:** ![Jeff\_Mackay](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jeff\_Mackay](https://community.make.com/u/Jeff_Mackay)\
**Post date:** [March 3, 2024, 9:19pm UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/3 "2024-03-03T21:19:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Mackay](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jeff\_Mackay](https://community.make.com/u/Jeff_Mackay)\
**Post date:** [March 7, 2024, 6:36am UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/4 "2024-03-07T06:36:59Z")

</div>

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…

 ![1](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/7/77b30669c009bb1a5a2c58a91e489eda2f37bb0b.jpeg)  
 ![2](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/e/3/e350c30e18c28e78d619e6f27cfb972a4e11e6eb.jpeg)  
 ![3](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/f/f/ff84cee5259c418e9a042618e56306a15ea57759.jpeg)  
 ![4](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/0/d/0d543c781168afd09bb18b67f3db1ffdb301b00b.jpeg)

---

<div class="post-metadata">

**Author:** ![Donald\_Mitchell](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/donald_mitchell/32/8749_2.png) [@Donald\_Mitchell](https://community.make.com/u/Donald_Mitchell)\
**Post date:** [March 8, 2024, 3:59pm UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/5 "2024-03-08T15:59:30Z")

</div>

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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/8/984b2a8e8035592897fa7d662940abc3869c3b64.png)

Follow that module with an Iterator so you can iterate those names  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/f/f/ffc94f9d18df784a09ddbc26e67027393dedab00.png)

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)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/7/1742e175a48ce72a6d6b2b6d94dd70a1425ed000.png)

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

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/7/d731107a34a37dfa9c9ec51cebd28d9353e33998.png)

Using Google Contacts Make an API Call, configure it like this:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/f/3/f3bf5f4335527db170c2fca85ba17e224195b53c.png)

`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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/5/e/5ee291ac93062bdd55d93c6af3f247ac650f1760.png)

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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/b/ab072ab581b95ace12f87ebe9e47813f06102697.png)

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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/a/9ad946cc4a309fb789218804f00d034e8e9499f9.png)

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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/f/af6ccd931fd904d7afa30772cb427d5f8e0d0ed1.png)

Finally, need to manipulate that output array a little bit to get all the email addresses out of it.  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/e/7e2a84ba676e77e5102370f4ec817f4e8be7f2c0.png)

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](https://community.make.com/uploads/short-url/wu39ZN22Fc1cHaZPD3nyHajD01g.json) (14.8 KB)

---

<div class="post-metadata">

**Author:** ![Jeff\_Mackay](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jeff\_Mackay](https://community.make.com/u/Jeff_Mackay)\
**Post date:** [March 11, 2024, 8:55pm UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/6 "2024-03-11T20:55:00Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [March 26, 2024, 7:18am UTC](https://community.make.com/t/filtering-a-google-contact-group-so-i-can-send-emails/29250/7 "2024-03-26T07:18:14Z")

</div>


