Hi everyone!
Leo here from Zapier Support, hope you're doing well today!
Occassionally, we get a question whether it’s possible to make a Zap work between certain hours and certain days, otherwise delay.
There are a couple of options available, but when it gets complex, it will often involve using Paths by Zapier. Now, we know that not everyone needs a Pro plan (or higher), so we set out for a fun challenge to create a Zap that can do the following, without using Paths, in the leanest way possible:
1/ Allow the Zap to continue, if the Zap is triggered between Monday and Saturday, 8 AM and 6 PM
2/ Before 8 AM on Mondays to Saturdays > delay until 8 AM today
3/ After 6 PM on Mondays to Fridays > Delay until 8 AM the next day
4/ After 6 PM on Saturday, or the entire Sunday > Delay until next Monday
The Solution:
Trigger: use the trigger of your liking
Action: Formatter > Date / Time > Format.
Use input: {{zap_meta_human_now}}
Output: custom value: ddd HH
Action: Lookup Row in Google Sheets
Search column A by output of step 2
Action: Delay by Zapier > Delay Until
Use custom value > output step 3
Action: use the action of your liking
The Google Sheet you’ll want to make a copy of and add to your Google Drive is found here: http://zpr.io/t5HZv
The spreadsheet has 169 rows (7 days x 24 hours + 1 row header) to see if a certain timestamp can run immediately, the next morning or next Monday. I have tried creating a sheet which is easier to modify (different hours) . For instance, if you want to run this Zap on Mondays to Fridays, same hours, you can change cells J5, K3, K4 and K5 to “Next Monday at 8 AM”.
Additionally, if you start earlier or later, you can change the 8 AM in all the colored cells to update column B automatically.
The only thing that can’t be automagically updated is the ending time. If you want to run this Zap between 8 AM and 4 PM, you’ll then need to update a couple or rows in Column B manually.
To make it a little easier, here’s a link to a Shared Zap to get this working: https://zapier.com/shared/da3d5d8901eea481002e0d6429dff1628bd7e6f4
How to get this working:
- You’ll first want to make a copy of the Google Sheet in your Google Drive. Sheet: http://zpr.io/t5HZv (click here for instructions on how to do that)
- Use the Shared link from above to make a copy of this template in your Zapier account
- Change the trigger to your liking
- Use the below extra details if you like
- Change the action step and add additional ones if needed
Some steps explained:
A/ Date formatting
As you can see in this screenshot, we’re changing the date time to ddd HH, so we can use that to look up how much the Zap will need to be delayed (if any).
B/ Lookup row
In this screenshot, you can see that we look up a row with the output from the date formatting step. This will allow us to retrieve the value to delay until for.
C/ Delay Until
With the result of the lookup-row step, we’ll be able to dynamically input the value for a delay until as a custom value, you can see that here.
You might wonder, what if my Zap runs on Monday 2 PM. According to the table, it will run at 8 AM, which is in the past. What will happen? Because of this setting, we can handle “past” events, up to 24 hours ago, which is well in our range.
Afterthoughts:
- It’s definitely possible to use a Formatter > Utilities > Lookup table instead of the Google Sheets step, but the data entry can take… a while
- Perhaps the date formatting and the lookup can be combined in one step by using Code by Zapier, but I’ll leave that challenge to you ;)
I hope this will make it a little easier to get this working.
Cheers,