Create Length Based Trigger
Only use this trigger type if you cannot use the Time Based or Item Based triggers.
This trigger is the most fragile, and should be a last resort if dealing with data that has no timestamps or identifiers.
Create triggers folder
Locate the your app folder in the apps directory and add a new triggers
folder if it doesn't exist already.
Create trigger file
Create a new file within your app's trigger folder. Call it something like new-trigger.trigger.ts
. Make sure it ends with .trigger.ts
.
Add your own values. We provided mock data to help initialize the process.
-
export const newTrigger = createTrigger
- replace newTrigger with the name of your trigger.
-
Add an id:
your-new-app_trigger_new-trigger
- Make sure the id follows the format
<app-id>_trigger_<trigger-name-in-kebab-case>
- Make sure the id follows the format
-
Add a name for your trigger
-
Add a brief one sentence description
-
Add an Input Config
This is used to generate the form for the UI to configure this action.
Read more about the Input Config
-
Define the
run
method.This method will run every time the trigger polls.
The common arguments used by this method are
configValue
andconnection
.-
configValue
represents the Input Config that was used when the user configured this trigger. -
connection
is the decrypted connection properties of the connection selected by the user when configuring this trigger.If using an oauth2 connection, do not worry about handling refresh tokens, that is handled by the engine. Just make the api call assuming the access token is valid.
Return all the items in the same order every time, because this length based trigger uses the number of items to determine what items are new and what items already trigger an execution.
It is very important that you return the all the items in the same order every time. This trigger is pretty fragile.
If you have 10 rows and they trigger, then next time the poller runs, it find 12 rows, then it will splice the first 10, and run the last 2.
Another example of how this behaves is, imagine you had 10 rows, and then suddenly you have 5. Now, the pointer changes from 10 to 5, and nothing triggers.
So the number of items and order is very important.
-
-
Define the
mock
method.The
mock
method is used by users when they want to generate a mock output instead of making an real api call to their third party integration.Ouput data is used to map to other nodes in the workflow builder. This is done by clicking
Save & Test
in the configuration form.