Skip to content

Triggers & Events

A trigger is what defines when a task should be created. When an event happens, AireFlow will create an instance of every task that is defined with a relevant trigger. A trigger is relevant if it matches the type and key of the event. There are two main types of event that can trigger tasks to be created, custom events and task events.

Custom Events

A custom event is an event published via the api, with an associated routing key.

Event Definitions

To trigger a task based on a custom event, define your event with a name and routing key via the Event Definitions page. Note that once a key is set it cannot be changed, so you will need to create a new event definition and re-add it to any triggers if your key needs to be changed.

The event definitions page can also be used to test workflows by manually firing events that would otherwise come from outside AireFlow.

Publishing Custom Events

Custom events are published via an HTTP POST request to https://{Your AireFlow Host}/Api/Event/{routingKey}/{subjectId}. The routing key is required, as it uniquely identifies the event and is the part of the event that a trigger has a reference to. The subject ID in the URL is optional, because it can also be specified in your workflow definition.

AireForms Integration

Custom event triggers can be used as a way of directing the output of AireForms into a Workflow. The AireFlow plugin is built into AireForms, so as long as it's enabled for the environment you're using, collecting the output of a form can be accomplished simply by using the correct routing key. The associated task will be triggered with the form XML as its context. When a AireForms form is submitted, the routing key is set by convention as {FORM_KEY}-{VERSION}. For example, if you had version 3 of a form with key about-me, then the routing key you should use in the Event Definition is about-me-3. This custom event can then be added to a workflow definition as a trigger.

In AireForms, if the form is a single pass form then the AireFlow delivery channel should be used. Whereas, if it’s a clinician form it can use the built in AireFlow plugin. Both methods rely on some configuration in the environment variables. For more information about this, please take a look at the AireForms documentation.

There is also support for directly using form lifecycle events.

Task Events

Task events are created by AireFlow itself, whenever task instances are created or updated. There are several specific types of task event.

EventWhen does it happen?
Task InstantiatedEvery time a task is created.
Task AssignedEvery time the assignee of a task is changed.
Task StartedWhenever the status of a task is changed to In Progress. If the Task is moved from New directly to Completed, this event will not happen.
Task CompletedWhen the status of a task is changed to Completed. This event occurs automatically for notification tasks, after the notification is sent.
Task FailedWhen the status of a task is changed to Failed. This event also occurs automatically for notification tasks, when a notification fails to be sent and all retry attempts have also failed.
Task CancelledWhenever the status of a task is changed to Cancelled.
Task BlockedWhen the status of a task is changed to Blocked.