Poll
Poll trigger is triggered when new items of a rest API are detected.
Usage
Watching new item in API https://jsonplaceholder.typicode.com/posts
response:
on:poll:url: https://jsonplaceholder.typicode.com/postsdeduplicationKey: id
Or, multiple urls:
on:poll:url:- https://jsonplaceholder.typicode.com/comments?postId=1- https://jsonplaceholder.typicode.com/comments?postId=2deduplicationKey: id
Note, the response structure should be same if using multiple urls
Options
url
, required,string
orstring[]
, the polling API URL, for example,https://jsonplaceholder.typicode.com/posts
, if using multiple urls the response structure should be same.itemsPath
, optional, if the API's returned JSON is not a list and is instead an object (maybe paginated), you can configureitemsPath
as the key that contains the results. Example:results
,items
,data.items
, etc... The default value isundefined
, which means the API's response should be a list. IfitemsPath
is not specified and the API's response is an object, the object will be converted to anitems
array.deduplicationKey
, optional. The poll trigger deduplicates the array we see each poll against the id key. If the id key does not exist, you should specify an alternative unique key to deduplicate, you can use path format, like:id
,data.id
,item.data.key
, If neither are supplied, we fallback to looking forkey
, if neither are supplied, we will hash the item, and generate a unique keyshouldIncludeRawBody
, optional,boolean
, the default value isfalse
, iftrue
, then you can use the whole body as you need. For example:on:poll:url: https://jsonplaceholder.typicode.com/postsshouldIncludeBody: trueconfig:limit: 5jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:rawBody: ${{ toJSON(on.poll.outputs.raw__body) }}run: |echo "rawBody: $rawBody"shouldIncludeRequest
, optional,boolean
, the default value isfalse
, iftrue
, then the request config will be added to the item's property__request
, for example:
on:poll:url: https://jsonplaceholder.typicode.com/postsshouldIncludeRequest: trueconfig:limit: 5jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:__request: ${{ toJSON(on.poll.outputs.__request) }}run: |echo "__request: $__request"
The __request
will be like { "url": "https://jsonplaceholder.typicode.com/posts" }
requestConfig
, optional, we use Axios for polling data, so your can pass all params that axios supported. For example:on:poll:url: https://jsonplaceholder.typicode.com/postsrequestConfig:method: POSTheaders:Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1lrequestConfig.axios-retry
, optional,axios-retry
params, you can configure the number of times to retry, for example:
on:poll:url: https://fb067a39e21871a3c38f8569d28d5aba.m.pipedream.net/requestConfig:axios-retry:retries: 3jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:title: ${{ on.poll.outputs.id }}run: |echo "title: $title"
You can use General Config for Actionsflow Trigger for more customization.
Outputs
Poll trigger's outputs will be the item of the API results
Note, is you set
shouldIncludeRawBody
, then you will getraw__body
for the whole raw body
An outputs example:
{"userId": 1,"id": 1,"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"}
You can use the outputs like this:
on:poll:url: https://jsonplaceholder.typicode.com/postsconfig:limit: 5jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:title: ${{ on.poll.outputs.title }}body: ${{ on.poll.outputs.body }}run: |echo "title: $title"echo "body: $body"