The Zapier loop through line items action is a godsend! For those of us who have been duct-taping together ways to loop through Google Sheets in Zapier, this action finally simplifies the process of looping through line items. Now you can perform tasks in bulk for each row in your sheet easily and quickly so you can get back to the important stuff!
This post will give an overview of the Zapier loop through line items action by using a Google Sheet of customer delivery information to send SMS and email alerts to customers if their order has been shipped. So without further ado let’s take it away!
Get Line Items from Google Sheets
The Customer Database sheet contains the First Name
, Order #
, Email Address
, and Phone Number
of each customer along with the Delivery Today?
checkbox field to designate whether their order will be delivered today.
As explained in the Zapier Google Sheets Quick-Start Guide there are a few different options for importing data from Google Sheets into Zapier depending on the number of rows or the amount of data that you want to import.
For this example, it is only necessary to import a small number of rows meaning the “Find Many Spreadsheet Rows” action from the Google Sheets app can be used. As shown in the images below, when the “Lookup Column” is set to the “Delivery Today?” column and the “Lookup Value” is set to TRUE then only the rows where this condition is matched will be pulled into the “Rows Col$” fields.
Need to read in more than 10 rows at a time? Explore the different options available in the Zapier Google Sheets Quick-Start Guide post so that you can choose the best option and know how to format the imported data correctly so that it can be used in subsequent actions.
Zapier Loop Through Line Items Workflow
Zapier Loop Through Line Items Action
Now that the customer information has been brought in from Step 2. each of the column values can be used in the “Values To Loop” section to form array variables, which we can then loop through. Make sure to select the “Looping by Zapier” app and the “Create Loop From Line Items” action event.
Note the 500 iteration limit that is imposed on the “Maximum Number Of Loop Iterations” field. If you have more than 500 rows to loop through then you will need to use a nested loop (see the Zapier For Each Loop Quick-Start Guide).
Once the looping variables have been setup in Step 3, they can then be used in subsequent steps to supply a different value for that variable for each iteration of the loop.
Send Email for Each Line Item
Send SMS for Each Line Item
If you want more information on how to get started with sending SMS with Telnyx, take a gander at the Marketo 2 Way SMS using Telnyx and Zapier post.
One thing to note about sending SMS is that there are rate limits that apply to certain number types so if you try and exceed these limits, which is very likely when you loop through arrays, then the carrier will throttle the messages and spread them out over a longer timespan to ensure delivery. Therefore, do not expect all your SMS to be delivered right away when looping.
This throttling is implemented to prevent fraudsters and bad actors from easily being able to spam people with large amounts of SMS at once. If higher rate limits are needed you can get verified by your carrier who can then increase your rate limit or allow you to purchase another number type with higher throughput e.g. a short code number. If you want to learn more about rate limits and the pros and cons of the different number types then take a look at the Marketo SMS Marketing with Telnyx post.
Post Loop Follow Up Actions
You might have been wondering “What if there are actions that I only want to do once after the loop has ended?”.
This is where the “Continue Once Loop Complete” filter comes into play. It uses the “Loop Iteration is Last” boolean value to check if there are any more iterations of the loop to complete. Once this value is true then this filter will allow the Zap to progress to the remaining steps which will be executed once only.
Notice how the content of the email and SMS summary messages is populated using the columns from Step 2 rather than one of the loop variables from Step 3. As shown in the email and SMS inbox images below, this results in one single summary email and SMS being sent containing all the customer information for orders that will be delivered today.
N.B. You’ll notice from the image above and the screenshot of the SMS messages below that the emails and SMS messages do not get sent in the expected order. If the order that the for loop executes in is important to you and you need email 3 to be sent before email 6 then take a look at using webhooks or delays.
What’s After Looping Through Line Items?
The Zapier loop through line items action is great but there have been 2 big limitations identified while we were working through this post:
- Not being able to pull in more than 20 rows from Google Sheets at once
- Not being able to loop more than 500 times
As always I’ve got you’ve covered 😉