Trigger (polling)

The trigger module is a special module that saves the information about the last item processed and continues the execution from that item.

You can configure the trigger module to:

  • process all available items and wait for new ones, without repeated processing of the old item.

  • process items starting from a specific date and time.

  • process items starting with a specific item.

Use this module when you need to process items sequentially in the order they were created or updated.

Components

Communication

The communication response is extended with the trigger object.

response.trigger

The trigger collection specifies directives that control how the trigger works and how your data is processed.

Key
Type
Description

type

Date or ID

Specifies how the trigger will behave and sort items

order

Asc or desc

Specifies in what order the remote API returns items

id

IML string

Must return the current item’s Id

date

IML string

When used, must return the current item’s date

response.trigger.type

Required: yes Values: id or date

This directive specifies how the trigger will sort and iterate through items.

If the processed item has a create/update date, then date should be used as a value and a correct method should be specified in the trigger.date directive. The trigger sorts all items by their date and id fields and returns only unprocessed items.

If the processed item does not have a create/update date, but only an id, then id should be used as a value, and a correct method should be specified in the trigger.id directive.

response.trigger.order

Required: yes Values: asc, desc or unordered

This directive specifies in what order the remote API is returning items - descending, ascending, or unordered. This information is needed to correctly determine if there are more pages to be fetched or not. It is also needed to correctly sort the incoming items and display them to the user in ascending order.

If the API returns items in ascending order (low to high), then asc should be used. If the API returns items in descending order (high to low), then desc should be used. If the API returns items in no specific order, then unordered should be used.

When specifying the trigger's communication, sort the results in descending order.

Make's limit is a return of 3200 records.

If you sort results in ascending order and the user has more than 3200 records, the trigger won't be able to fetch the latest records. We do not recommending using ascending order for polling triggers.

response.trigger.id

Required: yes

This directive specifies the item’s id. It must always be present.

For example, if the item looks like this:

{
    "id": 24,
    "name": "Fred",
    "friend_count": 5
}

then specify the trigger.id directive like this: {{item.id}}:

{
    "response": {
        "trigger": {
            "id": "{{item.id}}"
        }
    }
}

response.trigger.date

Required: yes, if the trigger type is date

This directive specifies the item’s date. It must be specified when the trigger.type is set to date. Note that trigger.id must always be specified.

For example, if the item looks like this:

{
    "id": 24,
    "name": "Fred",
    "friend_count": 5,
    "created_date": "2017-07-05T13:05"
}

then specify the trigger.date directive like this: {{item.created_date}}, and the trigger collection might look something like this:

{
    "response": {
        "trigger": {
            "id": "{{item.id}}",
            "date": "{{item.created_date}}"
        }
    }
}

Epoch

The Epoch panel is a specific component of the trigger allowing a user to choose the starting item.

Static Parameters

The trigger module can only have static parameters. There's no reason to have anything mappable in the trigger as this module is always the first module in the scenario.

Interface

The trigger module can return multiple bundles at once.

Samples

To help the users with setting up your module, provide samples.

Scope​

When using an OAuth type of connection, use the scope to define scopes required by this trigger.

Available IML variables

These IML variables are available for you to use everywhere in this module:

Variable
Description

now

Current date and time

environment

TBD

temp

Contains custom variables created via the temp directive.

parameters

Contains the module’s input parameters.

connection

Contains the connection’s data collection.

common

Contains the app’s common data collection.

data

Contains the module’s data collection.

data.lastDate

Returns the date from the last retrieved item in a previous execution.

data.lastID

Returns the ID of the last retrieved item in a previous execution.

scenario

TBD

metadata.expect

Contains the module’s raw parameters array in the way you have specified it in the configuration.

metadata.interface

Contains module’s raw interface array in the way you have specified it in the configuration.

Additional variables available for the response object:

Variable
Description

output

When using the wrapper directive, the output variable represents the result of the outputdirective.

Additional variables available after using the iterate directive, i.e. in wrapper or pagination directives:

Variable
Description

iterate.container.first

Represents the first item of the array you iterated.

iterate.container.last

Represents the last item of the array you iterated.

In the Trigger module, the iterate.container.last can be used for handling the pagination of the new items correctly/

"response": {
    "limit": "{{parameters.limit}}",
    "output": "{{parseItem(item.data)}}",
    "iterate": "{{body.data.children}}",
    "trigger": {
        "id": "{{item.data.name}}",
        "date": "{{parseDate(item.data.created_utc, 'X')}}",
        "type": "date",
        "order": "desc"
    }
},
"pagination": {
    "qs": {
        "after": "{{iterate.container.last.data.name}}"
    }
}

Additional variables available for pagination and response objects:

Variable
Description

body

Contains the body that was retrieved from the last request.

headers

Contains the response headers that were retrieved from the last request.

items

When iterating this variable represents the current item that is being iterated.

Example

Last updated