Polling Trigger
Periodically call endpoints to check for changes
The way polling triggers usually work is as follows:
On Enable: Store the last timestamp or most recent item id using the context store property.
Run: This method runs every 5 minutes, fetches the endpoint between a certain timestamp or traverses until it finds the last item id, and returns the new items as an array.
Testing: You cannot test it with Test Flow, as it uses static sample data provided in the piece. To test the trigger, publish the flow, perform the event, and wait for the run to be invoked (every 5 minutes) on the third party. Then check the flow runs from the main dashboard.
Examples:
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.
Last ID Strategy:
This strategy fetches new items based on the last item ID. To use this strategy, you need to implement the items method, which should return the most recent items. The library will detect new items after the last item ID.
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.