Polling library
There multiple strategy to implement polling triggers, and we have created a library to help you with that.Strategies
Timebased: This strategy fetches new items using a timestamp. You need to implement the items method, which should return the most recent items. The library will detect new items based on the timestamp. The polling object’s generic type consists of the props value and the object type.Trigger Implementation
After implementing the polling object, you can use the polling helper to implement the trigger.Republishing a running flow
When an enabled flow is published again and its polling trigger is unchanged (same piece, same piece version, same trigger, same inputs), Activepieces leaves the trigger running exactly as it was:onDisable and onEnable are not called, the trigger’s store is untouched, and polling continues on the same schedule. Events that arrive around the republish are picked up by the next poll as usual.
In the other cases (full table):
- Upgrading the piece version with the same inputs skips the old version’s
onDisableand runs the new version’sonEnablewithcontext.isRepublishset totrue. Use it to keep your checkpoint when your stored state is still valid.onDisablestill runs when the flow is turned off or deleted; on an upgrade, reuse anythingonEnablecreated outside the store (keep its id in the store) instead of creating it again. - Changing the trigger or its inputs runs both hooks without
isRepublish, so the trigger starts fresh. - Turning the flow off and on also starts fresh. This is how to reset a polling trigger whose stored state has gone bad, such as an expired sync token.
onEnable doesn’t overwrite it:
pollingHelper.onEnable and saves a snapshot built from the polled items, put this check before the helper call. On a republish the helper still fetches the items, so a snapshot saved after it would replace the one you meant to keep.