Best answer

queuing triggers of a zap

  • 23 March 2020
  • 5 replies
  • 1014 views

Hi Community,

we are using webhooks as trigger for our zap. the zap then proceeds to make an Rest API call to a third party service.

sometimes there are multiple webhooks coming in at the same time, thus triggering the zap multiple times, simultaneously. unfortunately the third party API has an rate-limit of 6 READ calls per 3000 ms. this occasionally causes the zap to hit an 429 when making the third party API call.

is there a way to queue the new trigger whenever the zap is still being run? ie running the zap sequentially rather than immediately when its triggered?

i would much appreciate any ideas. i did not find any solutions online.

thank you

thomas

icon

Best answer by amorevino 24 March 2020, 19:07

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 4
Badge +2

I don’t have a solid answer but I did think of a potential solution you might want to explore. What if when you received a webhook, you check a value in Zapier Storage, which is initially set at zero. If zero, then set the value to ‘1’ and finish the task at hand. When done, reset the value to zero.

Then, whenever a webhook comes in, it checks to see if the value = ‘1’. If so, that means it needs to wait for the other task to finish up and reset the value. During this time, you can add a delay of a minute or whatever makes sense for the other task to finish.

I haven’t fully thought this through so it’s entirely likely I am missing something obvious here. Perhaps even if I don’t have a fully baked idea, this might spark some ideas for you on how you might tackle this challenge?

Dear Donovan,

 

thanks for your reply. The waiting bit got me thinking.

 

as i am using custom javascript to do the third party api request, i added a sleep function like so, before doing the request.

 

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

let delay = Math.floor(Math.random() * 6000) + 1;
await sleep(delay);

 

This will not really make the zaps run sequentially but will spread out the requests over 6000ms in order to avoid the rate limit. theoretically, this will encounter a 429 when there are 13 simultaneous webhooks coming in. I prefer your idea with the zapier storage but i’ll have to experiment with that a bit more. i am not sure how the storage behaves if its called simultaneously by multiple zap runs. the sleep function will buy me some time for now... i hope (-: 

 

i hope this might help anyone encountering a similar issue in the future.

 

thomas

Userlevel 4
Badge +2

sounds like a good solution for now. I've been experimenting more with Zapier storage and it sure is handy having it around vs always using my goto, Airtable.

Userlevel 7
Badge +12

Those are both smart workarounds @donovanwatts  and @amorevino!

You could also look at using the Delay After Queue action that Delay by Zapier uses.

When you add it to a Zap, you can set a delay between each item and the Zap will basically create a queue where it holds each item until the appropriate time and then releases it on to the next step of the Zap. 

ed51bcf0673f5119397ac0a9c5c74d57.png
(View image larger)

@Danvers Thanks for your reply. i looked into that. the problem occurs when multiple runs of the same zap are initiated simultaneously, not in between the zap steps. so unfortunately the delay, will not resolve the issue.

nonetheless, thanks a lot for looking into this.