This article introduces the three categories of trigger that are available and how to configure each one.


Contents


Adding a trigger

  1. From the Editor, click on the trigger.

  2. Choose and configure the type of trigger.
    This can be Run Once, Schedule, or Webhook 

  3. Add a watcher, if required.
    Watchers can be notified by email or webhook.

  4. Save the trigger.


Run once trigger

This is the manual configuration, useful for ad hoc scripts and testing.

Once a Workflow is published you can run it; go to the Workflows screen, hover your pointer over the Workflowand click Run now.

All Workflows can be run by clicking Run now, not just those with a Run Once trigger.


Schedule

Schedule triggers enable a Workflow to be run at a specific time or at specific intervals, for example, every weekday at 7am or 5 minutes past the hour between 7am and 7pm on the first Saturday of each month.

There are two options for setting up a schedule:

  • Basic

  • Advanced

Basic

Basic schedules enable you to select the run frequency on a weekly scale.

In the following example, the Workflow will run every weekday at 7am:

Advanced

Advanced schedules use CRON syntax to specify the run times.

In the following example, the Workflow will run at 5 minutes past the hour between 7am and 7pm on the first Saturday of each month:

Checking your CRON syntax

Using a tool like https://crontab.guru/ is a great way to ensure your CRON syntax is as expected.

You can also see human-readable syntax for CRON jobs by clicking on your workflow and viewing the Information tab:

Cron formatting

A cron expression is a string comprising 6 or 7 fields separated by a space.

Field

Mandatory

Allowed values

Allowed special characters

Seconds

Yes

0-59

, - * /

Minutes

Yes

0-59

, - * /

Hours

Yes

0-23

, - * /

Day of month

Yes

1-31

, - * ? / L W

Month

Yes

1-12 or JAN-DEC

, - * /

Day of week

Yes

1-7 or SUN-SAT

, - * ? / L #

Year

No

empty, 1970-2099

, - * /

Cron expression examples:

Expression

Meaning

0 0 12 * * ?

Trigger at 12pm (noon) every day

0 15 10 * * ? 2021

Trigger at 10:15am every day during the year 2021

0 15 10 ? * 6L

Trigger at 10:15am on the last Friday of every month


Webhook

Webhooks are used to trigger Workflows by an event.

When selecting Webhook from the dropdown menu, there will be a Webhook URL:

By making a POST request to this URL, the workflow will be triggered.


Webhooks can also be used to trigger other workflows or send notifications about the Workflow to other systems, for example, Slack (see Watchers, below).


Watchers

Watchers will trigger a specific response when a Workflow stops running.

Distinct watchers can be set up to notify whether a workflow completes successfully or fails.

To add a watcher:

  • From the Trigger configuration pane, click ADD WATCHER.
    The following menu appears:

    From here, you can set two types of watcher:

    • User

    • Webhook

User watchers

Adding a watcher for a user will give that user notifications in the platform (the notification bell in the top-right hand corner).


Webhook watchers

Webhooks can be used to trigger other Workflows or to send notifications about the Workflow to other systems.


Triggering another Workflow

If a Workflow finishes successfully we might like to trigger another Workflow to run.

For example, Workflow 1 runs once a day and creates some transform tables we want to use in our analysis. Workflow 2 retrains our model. Workflow 3 performs the analysis for us.

We can add a watcher to Workflow 1 that triggers Workflow 2 by simply pasting the ‘Watcher URL’ from the trigger in Workflow 2. In the case below it will only trigger Workflow 2 for a successful run:


JSON Payload

Note that we have left the JSON payload empty; the Peak workflow triggers don’t require any payloads to cause a workflow to run.

This may beg the question: Why make separate Workflows? 

Generally best practice is to isolate as much as possible when programming, and workflows are no different. If we make changes to some of the code in Workflow 2 and it fails, we want to be able to make changes and then run Workflow 2 again without having to regenerate the tables in Workflow 1. We can do this just by using the ‘Run Now’ button! This will then trigger Workflow 3 as expected.


Slack notifier

Often when a workflow fails it can be useful to get a notification pushed to Slack so that you can react to a failure quickly. This also means that you don’t have to be logged into the platform to see when a Workflow has failed.

For details of how to set a Slack notifier up, see Setting up a Slack notifier for a Workflow.