Custom trigger with Duration input

I’ve been trying to create a custom automation with trigger every second/minute.
What I’m wondering is whether there’s some way to know what action user choose?, so I can pass data to webhook.
And Can I catch or create a webhook event to know whenever this trigger run? so I don’t need to use setInterval()


hi @mhung21

Welcome to the community! The interface element “Duration” doesn’t schedule on itself, it just returns the data the user picked (like “3 days”). If you want to schedule based on this data you need to do some coding yourself. You can use a Node NPM to help you achieving that, like “node-schedule”. Remember that Node will restart all by itself and you will loose the scheduled info, if you need persistent scheduling there are other NPM package that write to a database.

Probably an easier one is to use the built-in trigger “every time period”, see:

and use a custom action. With that integration recipe, will do the scheduling and calls your action endpoint every specified time.

Here are some more tips – let me know if they make sense and if you have additional questions!

Duration input – when the user configures this and creates the automation, you’ll get the value as an input field of your trigger.

Knowing what action a user chose – no, there’s no way to find out what action was connected to your trigger. You need to build your trigger to be atomic and work the same no matter what action it is connected to. This will let your users build more complex flows with your simple building block, too.

“Every time period” trigger – I think the smallest time increment for this is 1 day. If you want to trigger every X minutes or seconds, you need to build a custom trigger.

Code example – actually, I built a small demo of this a long time ago. Warning: the code is very outdated and it probably will not fully work, but if you want to get some ideas it’s in my Github profile: Link to example

Does that help?

Hello @basdebruin and @dipro
I think I’ve found a solution
I really appreciate your help

1 Like

Hello @mhung21,

We are glad that you found the solution!

Let us know if you need anything :slightly_smiling_face:

And thank you @basdebruin!