2 min read

How to trigger a Flow

Run automated workflows using Directus Flows. These can be triggered by user events, external webhooks or scheduled timepoints.
How to trigger a Flow

Directus has the ability to run automated workflows using Flows. These rely on a trigger to start. This article will cover what types of triggers Directus offers and how they trigger a workflow.

To trigger a Flow, you will need to complete the action configured in the workflow, whether that's creating, editing or deleting a record, or waiting for the scheduled time to pass.

Flows is a powerful communication tool that connects your workflows in an easy to use User Interface (UI).

To begin, click on the cog icon to open the settings, then click Flows. Create a new flow to open the trigger options window.

Name the flow accordingly and move onto the Trigger Setup. Here you are presented with all the different types of triggers.

Event Hook

This contains all the internal events that occur in Directus. Use this trigger if you want to run a workflow when a user performs an action. By default, this is an Action which will be processed separately from the internal workflows of Directus. If you want to process this workflow before anything else can run, use Filter to block everything (not recommended) until the workflow is finished.

To trigger an event hook, you must open one of the collections that were included in the scope. Then perform one of the selected action. For example, create a new record, edit an existing record or delete a record.

Webhook

This creates a URL endpoint in Directus that can be opened by an external application to trigger a workflow. There is the option to POST information or use the default GET to use external information inside the workflow. The link becomes available once the trigger is created.

To trigger a webhook, simply open the URL that was generated by Directus. If you chose to use the POST method, then you'll need an application like Postman to perform the POST action to the URL. The webhook is intended to be used by third party applications to interact with Directus.

Schedule

You can create a trigger at set intervals exactly like CRON and uses the same syntax (* * * 1 *). For those who are unfamiliar with this or need a refresher. It's in the following order: minutes, hours, day (of the month), month, day (of the week). This website is helpful: https://crontab.guru

To trigger a scheduled workflow, simply set the cron time to a few minutes time then wait for it to run, otherwise, wait for the scheduled time to pass.

Another Flow

This allows you to chain Flows together. There is no option to select the other flow, this must be done when creating the other flow. With this option you can have a collection of common flows which are triggered by various workflows.

This is a tricky one to trigger becuase it relies on another flow being triggered first. If you are unsure how it is triggered, open the other workflow, and note what the first step is. Perform that action and you will see both workflows triggered. If this has not happened, make sure to check the logs on both workflows to find out what stopped the workflow from completing.

Manual

This one allows your users to trigger this workflow on-demand for any of the selected collections.

To trigger this flow, open one of the your chosen collections and you'll see a new option in the right-hand side panel labelled Flows. Expand this section to reveal a button labelled with the name of the flow. Click the button and the workflow will run.

What's next?

Now that you can trigger a workflow in Flows, you can add Actions and Conditions to complete the aims of your workflow.

By continuing to use our website, you consent to use essential cookies. We also use optional tracking cookies which help us gather statistics to improve our services. Do you consent to these cookies?

I Consent Do not track