One of the many useful features of Zapier is the "Delay For" step.
However, one of its limitations is that delays must be a minimum of 1 minute.
In a lot of situations this might be too long, so I got to thinking about a way around this.
Once again, a Javascript Code step can help.
Reading the documentation, one of the limitations is as follows:
Code steps can run for up to 10 seconds before your zap will throw an error. So, what if we just create a Code step that does nothing for 10 seconds, then returns a dummy result?
Well, this does the job:
var now = new Date().getTime();
var millisecondsToWait = 9900; /* i.e. almost 10 seconds */
while ( new Date().getTime() < now + millisecondsToWait )
{
/* do nothing */
}
output = [{id: 123, hello: "world"}];
What this code does is get the current UNIX timestamp in milliseconds, then adds 9900 milliseconds to that timestamp (9.9 seconds).
A loop then constantly gets the current UNIX timestamp in milliseconds, and until it equals the previous number (i.e until another 9900 milliseconds has gone by) it keeps looping.
After that, it returns a dummy "hello = world" value and the zap continues on with the next step.
(PS - trial and error showed that waiting 10,000 milliseconds usually caused an error as it takes Zapier a few milliseconds more to run the complete script - 9900 worked well in testing).