Preventing sending emails to the same address multiple times
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!
Page 1 / 1
Hi @jordan_nest
You would have to add custom Code logic to remove duplicates.
Guide:
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.
@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.
@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
@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.
what would be an example of a common value to lookup all the rows?
@jordan_nest
Column: Lookup
Value: TRUE
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!
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.
@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.
@jordan_nest
This was the logic I suggested previously:
Trigger: Typeform - New Entry
Action: Formatter by Zapier - Text
Action: Google Sheets - Lookup Spreadsheet Rows
Used to get ALL of the GSheet Rows
Column: Lookup
Value: TRUE
Action: Code by Zapier - Run JavaScript
Used to do the location matching and deduplication logic
Returns list of unique emails to loop thru to send
Action: Looping by Zapier - Create Loop From Line Items
Loop thru the values returned from the Code step
Action: Microsoft Outlook - Send Email in Microsoft Outlook
Uses values from the Looping step
Thanks @Troy Tessalone ; although i don’t understand what you mean by:
Action: Google Sheets - Lookup Spreadsheet Rows
Used to get ALL of the GSheet Rows
Column: Lookup
Value: TRUE
Is Lookup, and TRUE values I can search on? This is my current search when I tried to do it with Locations:
@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
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
@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
Trigger: Typeform - New Entry
Action: Formatter by Zapier - Text
Not sure this step is even needed
Action: Google Sheets - Lookup Spreadsheet Rows
Used to get ALL of the GSheet Rows
e.g. If there are 10 rows in the GSheet then this will return all 10 rows
Column: Lookup
Value: TRUE
Action: Code by Zapier - Run JavaScript
Used to do the location matching and deduplication logic
e.g. if this is supposed to return 3 items to iterate thru, then the logic would determine the specific 3 items to return
Returns list of unique emails to loop thru to send
Action: Looping by Zapier - Create Loop From Line Items
Loop thru the values returned from the Code step
Action: Microsoft Outlook - Send Email in Microsoft Outlook
Uses values from the Looping step
@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.
@Troy Tessalone
My Steps
Trigger: Typeform - New Entry
This takes the Location that has been specified by the buyer
Action: Formatter by Zapier - Text
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.
The split text is required to split each location out to line items
The locations need to be passed through so the automation knows which email addresses to distribute the data to.
Action: Google Sheets - Lookup Spreadsheet Rows
Used to get ALL of the GSheet Rows
e.g. If there are 10 rows in the GSheet then this will return all 10 rows
Column: Lookup
Value: TRUE
You specified the above is needed, but this just focussed on the emails, where as i require the location
Action: Code by Zapier - Run JavaScript
Used to do the location matching and deduplication logic
e.g. if this is supposed to return 3 items to iterate thru, then the logic would determine the specific 3 items to return
Returns list of unique emails to loop thru to send
Action: Looping by Zapier - Create Loop From Line Items
Loop thru the values returned from the Code step
Action: Microsoft Outlook - Send Email in Microsoft Outlook
Uses values from the Looping step
@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.
@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,
A customer selects N1, N12, N4
The automation is looking up all the emails related to it
Previously what was happening was, because it identifies j*****@hotmail.com for each location selected, the email is sent each time
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.
@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.
I’ve got it working now, thank you so much for your help @Troy Tessalone !!
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.