Skip to main content

Sometimes you'll need your Zap(s) to detect if something has triggered after hours, and if so to add on a delay until business hours again. So, for example, if someone submits a form at 8pm, wait until 8am the next day. The Tricky Part is that the Zap can trigger the day before (e.g. 8pm) or it can be the same day that you want to send, but not business hours yet (e.g. 3am). So how do you set the delay?

I'd love to explore some of the available options both with and without utilizing Paths.


Hi Jesse,

In my Zap I was used Small Javascript Code and the Delay Zapier APP to achieve this kind of zap execution.

I used code by zapier to perform time calculation and delay to add delay of calculated time.

Happy to learn any other better way. :)

Thanks




@sudesh thanks for the reply! Are you able to share some screenshots and a description of your setup? I'm sure several folks would benefit from seeing a visual. :)



Here are some ways I've figured out how to accomplish this, entirely without Paths (they were conceived before paths were even a thing, haha). You could certainly "path-ize" them instead of using multiple Zaps.

1) Using 2 Zaps when weekends have business hours — One for during business hours and one for outside


Zap 1 (outside business hours)

Trigger: Whatever you choose 

Action: Formatter -- Format Date (to only show the hour, in 24-hour format) 

Filter: Only continue if that number is greater than rwhatever your closing time is...20 for example] or less than opening time, like 07 

Action: Formatter -- Spreadsheet-Style Formula (if statement...if Formatter output is greater than 20 output “tomorrow”, otherwise output “today”) 

Action: Delay Until -- goutput of IF statement] at 7am (this will either be tomorrow at 7am, or today at 7am) 

Action: Whatever your final action is


Zap 2 (during business hours)

Trigger: Whatever you choose

Action: Formatter -- Format Date (to only show the hour, in 24-hour format)

Filter: Only continue if that number is greater than opening hour and less than closing hour

Action: Whatever your final action is


2) Using 1 Zap when weekends have business hours — Lookup table for how many hours to delay, based on what time it is

Trigger: Whatever you choose

Action: Formatter -- Format Date (to only show the hour, in 24-hour format)

Action: Formatter -- Lookup Table (number of hours to delay...so for 00 it's 7, for 01 it's 6, etc. and fallback of 0 for when it's within business hours)

Action: Delay For ooutput above] hours (if not one of the options, defaults to 0 hours and proceeds to action right away)

Action: Whatever your final action is


3) Using 2 Zaps when weekends DON'T have business hours — One for during the week and one for the weekend


Zap 1 - During the week

Trigger: Whatever you choose

Action: Formatter -- Formate Date (to only show the day of the week)

Filter: Only continue if the day is Monday, Tuesday, Wednesday or Thursday

Action: Formatter -- Format Date (to only show the hour, in 24-hour format)

Action: Formatter -- Lookup Table (number of hours to delay...so for 00 it's 7, for 01 it's 6, etc. and fallback of 0 for when it's within business hours)

Action: Delay For poutput above] hours (if not one of the options, defaults to 0 hours and proceeds to action right away)

Action: Whatever your final action is


Zap 2 - Going for the weekend

Trigger: Whatever you choose

Action: Formatter -- Format Date (show day of the week AND the hour in 24-hour format — like Mon 16)

Filter: Only continue if that output is in (Fri 17, Fri 18, Fri 19, Fri 20, Fri 21, Fri 22, Fri 23) OR contains Saturday OR contains Sunday


Image%202018-07-02%20at%205.00.43%20PM.pngAction: Delay Until next Monday at 9 am

Action: Whatever your final action is


If you notice anything that's inaccurate or that could be more clear, please let me know!



We have a Zap that requires conditional logic for determining whether or not it triggers after hours, but didn't require the delay. So this only addresses the issue of whether it's inside or outside business hours (also taking into account weekends.)

One concern was making sure there was no confusion about timezone or Daylight Savings Time. In this case, business hours are 6 AM to 6 PM Pacific Time, Monday through Friday. Since different users have different timezones in their Zapier profile settings, to avoid confusion, we didn't want to use {{zap_meta_human_now}}. Unfortunately, using {{zap_meta_pst_iso}} or {{zap_meta_pdt_iso}} would require that we then determine whether it was daylight savings time or not. 

A simpler solution was to use "To Timezone" inside Formatter by Zapier Date / Time. Additionally, the only things we actually needed was the current day of the week and hour of day, and we separated these with a pipe, so our format was just "d|H". Here's the screenshot of the Formatter Action:

image.pngWe then had some simple logic to determine whether it was during or outside business hours:

image.pngThe code should be clear enough to understand, but let me know if you need explanation. Hope someone finds this helpful!



@john_fohrman this is great, thanks for sharing! @sudesh is this similar to your approach? I'd love to see which solution has the least amount of steps and I wonder if there is room for further collaboration here!



@jesse Yes this is same like as my approach that I used.