Skip to main content
Best answer

Preventing sending emails to the same address multiple times


Forum|alt.badge.img

There are going to be cases where my business partners operate in multiple locations.

I’m having an issue whereby, when a location is selected by the customer and a partner operators in multiple locations, they receive an email with the customer information twice. The customer information would just be a duplication so is unnecessary. 

Is there a way to prevent this? 

Thanks in advance!

 

 

 

Example of business partners operating in multiple locations
My zap 

 

Best answer by Troy TessaloneBest answer by Troy Tessalone

@jordan_nest 

Using your example, there are 6 rows shown in the screenshot.

When the GSheet Lookup Rows step runs it will return 6 rows.

You need to pass the necessary GSheet data points (Locations, Email) into the Code step.

You also need to pass the Location from the Typeform into the Code step.

That way the Code step has the Location info from the Typeform and the Location/Email info from the GSheet.

Now the Code can be configured to first use the Typeform Location to derive the matching GSheet Locations/Emails. (e.g. from 6 possibilities to 3 possibilities)

Then the Code can be configured to do deduplication. (e.g. from 3 to 1)

The data returned from the Code step would be the 1 email that needs to be processed thru the Looping step.

Each unique item processed the the Looping step would then be sent an email.

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

22 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 7, 2024

Hi ​@jordan_nest 

You would have to add custom Code logic to remove duplicates.

Guide:

 


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 7, 2024

Thanks troy, but unfortunately this doesn’t work as I have a loop which checks each of the locations and finds the associated email. If the email appears multiple times, it sends a the email for each time the associated locations are selected. 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 8, 2024

@jordan_nest 

Change the order of operations for the Zap step logic.

Before looping, find all of the locations from the GSheet, then use the Code step to determine the matching locations as well as do the deduplication, so you are left with the unique emails to send thru the looping.


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 9, 2024

@Troy Tessalone  thanks for all your help in this. 

 

Still struggling even when i re-arrange the code steps. For some reason, having the GSheet lookup after the formatter, it isn’t able to recgonise the locations. However, when the loops is in place it does. As a result it isn’t able to progress to the code block

 

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 9, 2024

@jordan_nest 

GSheet Lookup Value fields don’t accept arrays.

You would need to add another column with a common value to use to lookup ALL the GSheet rows to then be processed by the Code step.

The Code step would come before the Looping step.

 

If you need help, consider hiring a Certified Zapier Expert: https://zapier.com/experts


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 14, 2024

what would be an example of a common value to lookup all the rows?


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 14, 2024

@jordan_nest 

Column: Lookup

Value: TRUE


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7547 replies
  • December 19, 2024

Hi ​@jordan_nest 👋

Just came across this and wanted to check how you’re getting on? 

Let us know whether you’re in need of any further help here—keen to ensure this gets sorted!


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

Thanks ​@SamB, but still struggling to get this resolved. I’m going to look into this again and see if i can figure out an alternate approach.


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

@Troy Tessalone i have emails which acts as the unique differentiation between the different partners but this still doesn’t work.

I also can’t put the code step before the looping because it needs to split the duplicate emails which is driven from the google sheet. When a customer selects a location, they don’t know any other details. The automation is used to select the partners based on the locations, therefore locations is the only field i can pass through. 

 

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 22, 2024

@jordan_nest 

This was the logic I suggested previously:

  1. Trigger: Typeform - New Entry
  2. Action: Formatter by Zapier - Text
  3. Action: Google Sheets - Lookup Spreadsheet Rows
    1. Used to get ALL of the GSheet Rows
    2. Column: Lookup
    3. Value: TRUE

  4. Action: Code by Zapier - Run JavaScript
    1. Used to do the location matching and deduplication logic
    2. Returns list of unique emails to loop thru to send
  5. Action: Looping by Zapier - Create Loop From Line Items
    1. Loop thru the values returned from the Code step
  6. Action: Microsoft Outlook - Send Email in Microsoft Outlook
    1. Uses values from the Looping step

Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

Thanks ​@Troy Tessalone ; although i don’t understand what you mean by:
 

  1. Action: Google Sheets - Lookup Spreadsheet Rows
    1. Used to get ALL of the GSheet Rows
    2. Column: Lookup
    3. Value: TRUE

 

Is Lookup, and TRUE values I can search on? This is my current search when I tried to do it with Locations:

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 22, 2024

@jordan_nest 

The core of the logic is done in the custom Code step.

 

Previous feedback:

You would need to add another column with a common value to use to lookup ALL the GSheet rows to then be processed by the Code step.

  • Column: Lookup
    • Column can be named whatever you want
  • Value: TRUE
    • Value can be whatever you want as long as it is the same value for ALL row you want to find/return

 

If you need help, consider hiring a Certified Zapier Expert: https://zapier.com/experts


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

When I run the lookup earlier, however, it isn’t able to identify all the items that were split because it hasn’t been through the loop yet

 

 


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 22, 2024

@jordan_nest 

It seems you are still misunderstanding the fundamental logic that is being recommended.

 

Row | Lookup | Location | Email

1 | TRUE | A | X

2 | TRUE | B | Y

3 | TRUE | C | Z

 

Steps

  1. Trigger: Typeform - New Entry
  2. Action: Formatter by Zapier - Text
    1. Not sure this step is even needed
  3. Action: Google Sheets - Lookup Spreadsheet Rows
    1. Used to get ALL of the GSheet Rows
      1. e.g. If there are 10 rows in the GSheet then this will return all 10 rows
    2. Column: Lookup
    3. Value: TRUE

  4. Action: Code by Zapier - Run JavaScript
    1. Used to do the location matching and deduplication logic
      1. e.g. if this is supposed to return 3 items to iterate thru, then the logic would determine the specific 3 items to return
    2. Returns list of unique emails to loop thru to send
  5. Action: Looping by Zapier - Create Loop From Line Items
    1. Loop thru the values returned from the Code step
  6. Action: Microsoft Outlook - Send Email in Microsoft Outlook
    1. Uses values from the Looping step


 


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

@Troy Tessalone apolgoies - its still not working. It needs the locations to know which emails to send to. Currently set up how you suggested just sends the emails to every business partner. 

The duplication aspect worked perfectly in only sending 1 email, however, it should only send the email to the partners which are associated to the location.


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 22, 2024

@Troy Tessalone 

My Steps

  1. Trigger: Typeform - New Entry
    1. This takes the Location that has been specified by the buyer
  2. Action: Formatter by Zapier - Text
    1. Because the data comes from Typeform, if a user specifies more than 1 locations, which is highly probably, Typeform parses the data like N1, N2, N3.
    2. The split text is required to split each location out to line items
    3. The locations need to be passed through so the automation knows which email addresses to distribute the data to. 
  3. Action: Google Sheets - Lookup Spreadsheet Rows
    1. Used to get ALL of the GSheet Rows
      1. e.g. If there are 10 rows in the GSheet then this will return all 10 rows
    2. Column: Lookup
    3. Value: TRUE

    4. You specified the above is needed, but this just focussed on the emails, where as i require the location

  4. Action: Code by Zapier - Run JavaScript
    1. Used to do the location matching and deduplication logic
      1. e.g. if this is supposed to return 3 items to iterate thru, then the logic would determine the specific 3 items to return
    2. Returns list of unique emails to loop thru to send
  5. Action: Looping by Zapier - Create Loop From Line Items
    1. Loop thru the values returned from the Code step
  6. Action: Microsoft Outlook - Send Email in Microsoft Outlook
    1. Uses values from the Looping step

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • December 23, 2024

@jordan_nest 

All of the GSheet rows and the locations from Typeform would be sent to the Code step.

The Code step would take the location from Typeform and derive the matching rows from all of the GSheet rows sent in to the GSheet, then do any deduplication.


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 23, 2024

@Troy Tessalone - firstly really appreciate your continued support here. The code isn’t taking the location.

 

My gsheet is setup as follows, with the ID column acting as the common filed to LOOKUP all fields. The code block is performing the deduplication, but what is happening is that,

  1. A customer selects N1, N12, N4
  2. The automation is looking up all the emails related to it
  3. Previously what was happening was, because it identifies j*****@hotmail.com for each location selected, the email is sent each time 
  4. Now with the updated flow as above, its not even passing the location and is just emailing every email listed. 

My assumption is that the location isn’t being passed throiugh the location automation after it has been split in the Formatter

 

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting.


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31068 replies
  • Answer
  • December 23, 2024

@jordan_nest 

Using your example, there are 6 rows shown in the screenshot.

When the GSheet Lookup Rows step runs it will return 6 rows.

You need to pass the necessary GSheet data points (Locations, Email) into the Code step.

You also need to pass the Location from the Typeform into the Code step.

That way the Code step has the Location info from the Typeform and the Location/Email info from the GSheet.

Now the Code can be configured to first use the Typeform Location to derive the matching GSheet Locations/Emails. (e.g. from 6 possibilities to 3 possibilities)

Then the Code can be configured to do deduplication. (e.g. from 3 to 1)

The data returned from the Code step would be the 1 email that needs to be processed thru the Looping step.

Each unique item processed the the Looping step would then be sent an email.


Forum|alt.badge.img
  • Author
  • Beginner
  • 18 replies
  • December 24, 2024

I’ve got it working now, thank you so much for your help ​@Troy Tessalone !!


JammerS
Forum|alt.badge.img+6
  • Zapier Staff
  • 2382 replies
  • December 25, 2024

Wow! Thank you for confirming that Troy’s resolution got the Zap running. This will significantly help our Community members to have as a reference for the same issue.