mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Revert "added most media, operations info, and made small tweaks on flow and triggers"
This reverts commit 3c35b8d728.
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
|
||||
## What's a Flow?
|
||||
|
||||
![What's a Flow?]()
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Flows enable custom, event-driven data processing and task automation within Directus. Each Flow is composed of one
|
||||
Trigger, followed by a series of Operations.
|
||||
@@ -54,7 +56,7 @@ To create a Flow, follow these steps:
|
||||
6. On the Trigger Panel, click <span mi>add</span> and the **Create Operation** side menu will open.
|
||||
7. Set a name, select the [Operation](configuration/flows/operations) type, and configure as desired.\
|
||||
The unique name will be converted into an Operation Key, used on the [Flow Object](#the-flow-object).\
|
||||
If no name is set, a name and key will be auto-generated.
|
||||
If no name is set, one will be auto-generated for you.
|
||||
8. When done, click <span mi btn>done</span> in the Page Header to confirm and return to the Flow Grid Area.
|
||||
9. On the newly created Operation Panel:
|
||||
- Click <span mi icon>add</span> to add Operation after successful execution of the current Operation.
|
||||
@@ -63,20 +65,26 @@ To create a Flow, follow these steps:
|
||||
|
||||
## The Flow Object
|
||||
|
||||
When a Flow is triggered, a JSON object is created to store all data generated within the Flow. When you create an
|
||||
Operation, a key is generated. This key is appended to the Flow Object when the Operation executes. It is used to add
|
||||
the associated Operation's data onto the Flows Object. As each Operation in the Flow executes, it has access to the Flow
|
||||
Object and therefore the data generated from preceding Operations.
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
The JSON following is an example of a simple Flow with two Operations. The `$trigger`, `$last`, and `$accountability`
|
||||
keys are included on every Flow. An Operation key will be generated for each Operation that executes successfully.
|
||||
When a Flow is triggered, a JSON object is created to store all data generated within the Flow. When you create an
|
||||
Operation, you are required to add a unique name for it, which into turned into a key. This key is used to add the
|
||||
associated Operation's data onto the Flows Object. Each Operation in the Flow has access to the Flows Object, and
|
||||
therefore the data generated from the preceding Operations.
|
||||
|
||||
This following is an example of a simple Flow with two Operations. The `$trigger`, `$last`, and `$accountability` keys
|
||||
are included on every Flow, though their values will differ. The name and number of Operation keys will obviously depend
|
||||
on how you configure your Flow and whether each Operation executes successfully and actually appends data onto the Flow
|
||||
Object.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"$trigger": {}, // Data generated by the Flow's Trigger.
|
||||
"$last": null, // Data from the last Operation in the flow, for easy access!
|
||||
"$accountability": {}, // Provides details on who/what tripped the Trigger and generated this Flow Object.
|
||||
"operation_key": { // The data (if any) generated by the first Operation.
|
||||
"$trigger": {}, // Data generated by the Flow's Trigger.
|
||||
"$last": null, // Data from the last Operation in the flow, for easy access!
|
||||
"$accountability": {}, // Provides details on who/what tripped the Trigger and generated this Flow Object.
|
||||
"operation_key": { // The data (if any) generated by the first Operation.
|
||||
"some_nested_key": "Some nested value.",
|
||||
},
|
||||
"operation_key_2": null, // Value is null if no data was generated from an Operation.
|
||||
@@ -85,21 +93,26 @@ keys are included on every Flow. An Operation key will be generated for each Ope
|
||||
|
||||
### Flow Variables
|
||||
|
||||
The Flow Object's keys serve as variables, allowing data access from every Flow Operation. Variables must be passed
|
||||
using the following double-moustache syntax. You can even use dot-notation to extract sub-nested values.
|
||||
The Flow Object's keys serve as variables, allowing data access from every Flow Operation.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"operation_key_3": {
|
||||
"user": "{{ $accountability.user }}",
|
||||
}
|
||||
"operation_key_3": {{$trigger}}
|
||||
}
|
||||
```
|
||||
|
||||
You can even use dot-notation to extract sub-nested values.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"operation_key_3": {{operation_key.some_nested_key}}
|
||||
}
|
||||
```
|
||||
|
||||
## Logs
|
||||
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/docs/v9/configuration/flows/flows/flows-20220603A/logs-20220603A.mp4" type="video/mp4" />
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
As seen in the Sidebar, Logs store information each time the Flow executes. Each log will display information from
|
||||
|
||||
@@ -6,164 +6,159 @@
|
||||
|
||||
[[toc]]
|
||||
|
||||
:::tip Before You Begin
|
||||
|
||||
Please be sure to read the documentation on [Flows](/configuration/flows/flows) and [Triggers](flows/triggers).
|
||||
|
||||
:::
|
||||
|
||||
## Condition
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Routes to the next success or failure Operation based on some conditional `if` / `else` logic defined by a Filter query.
|
||||
That means if the query condition is met, the flow will move forward with the success Operation. Otherwise, the failure
|
||||
Operation will be initiated.
|
||||
Routes to the next flow based on some conditional `if` / `else` logic defined by a Filter query. That means if the query
|
||||
condition is met, the flow will move forward with the success Operation. Otherwise, the failure Operation will be
|
||||
initiated.
|
||||
|
||||
- **Condition Rules** — Create conditions with [Filter Rules](/configuration/filter-rules).
|
||||
### Options
|
||||
|
||||
- **Condition Rules** — Creates conditions with [Filter Rules](/configuration/filter-rules).
|
||||
|
||||
## Create Data
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Creates some Item(s) in a Collection.
|
||||
Creates Items in a Collection.
|
||||
|
||||
- **Collection** — Use the dropdown to set the Collections to create Items in.
|
||||
- **Permissions** — Set the scope of permissions used for this write operation.
|
||||
- **Emit Events** — Toggle whether the event is emitted.
|
||||
- **Payload** — Create Item(s) in a Collection. To learn more, see [API > Items](reference/items/).
|
||||
### Options
|
||||
|
||||
- **Collection** — Provides a dropdown to set the Collection to initialize data write.
|
||||
- **Permissions** — Sets the scope of permissions used for this write operation.
|
||||
- **Emit Events** — <!-- Not sure what this is -->
|
||||
- **Payload** — Creates the Item to write into the database using JSON with keys that match the Collection Fields.
|
||||
|
||||
:::tip
|
||||
|
||||
Make sure the Operation is scoped with the [permissions](configuration/users-roles-permissions) necessary to create
|
||||
Items.
|
||||
Make sure the Operation is set with the proper write permissions.
|
||||
|
||||
:::
|
||||
|
||||
## Delete Data
|
||||
|
||||

|
||||
|
||||
Deletes some Item(s) from a Collection by ID or query.
|
||||
|
||||
- **Permissions** — Set the scope of permissions used for this Operation.
|
||||
- **Collection** — Use the dropdown to set the Collection to delete Items from.
|
||||
- **IDs** — Set Item IDs and press enter to confirm. Click the ID to remove.
|
||||
- **Query** — Delete Item(s) in a Collection which match the query. To learn more, see
|
||||
[Filter Rules](/configuration/filter-rules).
|
||||
|
||||
:::tip
|
||||
|
||||
Make sure the Operation is scoped with the [permissions](configuration/users-roles-permissions) necessary to delete
|
||||
Items.
|
||||
|
||||
:::
|
||||
|
||||
## Read Data
|
||||
|
||||

|
||||
|
||||
Reads Item(s) form a Collection and adds them onto the Flow Object. You may select Items by their ID or run a query to
|
||||
select the Items you wish to update.
|
||||
|
||||
- **Permissions** — Defines Role that this data operation will inherit permissions from.
|
||||
- **Collections** — Select the Collection to read Items from.
|
||||
- **IDs** — Input ID for Item(s) you wish to read and press enter. Click the ID to remove.
|
||||
- **Query** — Filter Items with a query. See [Filter Rules](/configuration/filter-rules).
|
||||
|
||||
## Update Data
|
||||
|
||||

|
||||
|
||||
Updates Item(s) in a Collection. You may select Items by their ID or run a query to select the Items you wish to update.
|
||||
|
||||
- **Permissions** — Defines Role that this Operation will inherit permissions from.
|
||||
- **Collections** — Select the Collection to read Items from.
|
||||
- **IDs** — Input ID for Item(s) you wish to read and press enter. Click the ID to remove.
|
||||
- **Payload** — Updates Item(s) in a Collection. To learn more, see [API > Items](reference/items/).
|
||||
- **Query** — Filter Items with a query. See [Filter Rules](/configuration/filter-rules).
|
||||
|
||||
## Log to Console
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Output something to the console. This will appear in both the server side and in-app Sidebar Console Log. This is a key
|
||||
Output something to the console. This will appear in both the server side and in-app Sidebar Console Log. This is key
|
||||
tool to help troubleshoot Flow configuration.
|
||||
|
||||
- **Message** — Sets a [log message](#configuration/flows/flows/logs).
|
||||
### Options
|
||||
|
||||
:::tip
|
||||
|
||||
This will be delivered to your in-app Log Panel and also logged to the server-side console.
|
||||
|
||||
:::
|
||||
- **Message** — Input a [log](#configuration/flows/flows/logs) message.
|
||||
|
||||
## Send Email
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Sends email(s). Flow Object keys can be used as variables. This means an array of emails from a previous step in Flows
|
||||
could be used.
|
||||
Sends emails to other humans. Variables can be used so that an array of emails could be fetched from a previous step in
|
||||
Flows.
|
||||
|
||||
### Options
|
||||
|
||||
- **To** — Sets email addresses. Hit `↵` to save the email. Click an email to remove it.
|
||||
- **Subject** — Set subject line.
|
||||
- **Body** — Provides WYSIWYG editor to create email body.
|
||||
|
||||
:::tip
|
||||
:::tip Sending emails locally
|
||||
|
||||
If you are testing out this Operation locally from `localhost:8080`, be sure to check your spam box as your email
|
||||
provider may send it there automatically.
|
||||
If you are testing out this Operation from `localhost:8080`, be sure to check your spam box as your email provider may
|
||||
send it there automatically.
|
||||
|
||||
:::
|
||||
|
||||
## Send Notification
|
||||
|
||||

|
||||
<!-- Still Not working for me -->
|
||||
|
||||
Sends a notification to an app user.
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
- **Users** — Defines a user by their primary key UUID. Use [Flow keys](/configuration/flows/flows/#the-flow-object) to
|
||||
set this dynamically.
|
||||
- **Permissions** — Defines Role that this Operation will inherit permissions from.
|
||||
Send a notification to app user(s).
|
||||
|
||||
### Options
|
||||
|
||||
- **Users** — <!-- The @ does not autofill users.... idk the syntax -->
|
||||
- **Title** — Sets the notification title.
|
||||
- **Message** — Sets the main body of the notification.
|
||||
|
||||
## Read Data
|
||||
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Read Item(s) from the Database and adds them onto the Flow Object.
|
||||
|
||||
### Options
|
||||
|
||||
- **Mode** — Provides dropdown menu to read one Item, multiple Items, or Items by query.
|
||||
- **Permissions** — Defines Role that this data operation will inherit read permissions from.
|
||||
- **Collections** — Select the Collection to read Items from.
|
||||
- **IDs** — Input ID for Item(s) you wish to read and press enter.
|
||||
- **Query** — Filter Items with a query. See [Filter Rules](/configuration/filter-rules).
|
||||
|
||||
## Webhook / Request URL
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Makes a request to another URL.
|
||||
Makes a request to a URL.
|
||||
|
||||
- **Method** — Choose to make a GET, POST, PATCH, DELETE, or other type of request.
|
||||
### Options
|
||||
|
||||
- **Method** — Choose to make a GET or POST request.
|
||||
- **URL** — Define the URL to send request to.
|
||||
- **Headers** — Create new `header:value` to pass along with the request.
|
||||
- **Request Body** — Set request body data. Use any string or JSON.
|
||||
- **Data** — Defines any data to send off in the webhook.
|
||||
|
||||
## Sleep
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Pauses Operation Execution on the Flow for a given amount of milliseconds. Then continues to the next Operation.
|
||||
Pauses Operation Execution in the Flow for a given amount of milliseconds before moving to the next Operation.
|
||||
|
||||
- **Milliseconds** — Define the number of milliseconds to pause.
|
||||
### Options
|
||||
|
||||
- **Milliseconds** — Defines the number of milliseconds to pause.
|
||||
|
||||
## Transform Payload
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Transform Payload simply creates a new key on the Flow Object with nested JSON data. This provides a clean space where
|
||||
you can combine data from multiple Flow keys all into one object. So for example, if you needed to use the same data
|
||||
multiple times _(e.g. send it in a web request and also use it to create an Item in a Collection)_, you can combine the
|
||||
data one time with Transform Payload, then use it again and again.
|
||||
Alters the Flow's JSON payload. Allows you to insert custom-defined JSON into the Flow Object.
|
||||
|
||||
- **JSON** — Define JSON to insert into the Flow Object.
|
||||
### Options
|
||||
|
||||
- **JSON** — Defines JSON to insert into the Flow Object for this Operation.
|
||||
|
||||
## Trigger Flow
|
||||
|
||||

|
||||
<!-- Can't get it to work -->
|
||||
|
||||
This Operation starts another Flow and passes data to it. It should be used in combination with the
|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
This Operation starts another Flow. It should be used in combination with the
|
||||
[Another Flow](/configuration/triggers/#another-flow) Trigger.
|
||||
|
||||
- **Flow** — Define a Flow by its primary key UUID.
|
||||
- **Payload** — Define JSON to insert into the Flow Object.
|
||||
### Options
|
||||
|
||||
- **Flow** —
|
||||
- **Data** —
|
||||
|
||||
@@ -1,53 +1,64 @@
|
||||
# Triggers
|
||||
|
||||
> Each Flow is triggered by some internal or external event.
|
||||
|
||||
[[toc]]
|
||||
|
||||
## Event Hook
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Triggered by platform or data events. Event Hook logic is based on [Custom API Hooks](/extensions/hooks/).
|
||||
The Flow is triggered from platform or data events. The Event Hook logic is based around the Directus platform's
|
||||
[Custom API Hooks](/extensions/hooks/).
|
||||
|
||||
- **Type** — Choose the type of Event Hook:
|
||||
- **Filter (Blocking)** — Fires "blocking" right before the database transaction is committed, allowing you to tweak
|
||||
the payload or even outright prevent the completion.
|
||||
- **Action (Non-Blocking)** — Does not block anything. Therefore, this is mostly useful for doing things in response
|
||||
to an event, without slowing down the API.
|
||||
- **Scope** — Set the specific events which trip this Trigger.
|
||||
- **Collections** — Set the Collections which trip this Trigger.
|
||||
- **Response Body** — Set the Flow Object Key to use as a response body for Filter Hooks.
|
||||
- **Scope** — Sets the specific events which trip this Trigger.
|
||||
- **Collections** — Sets the Collections which trip this Trigger.
|
||||
- **Response Body** — Sets the Flow Object Key to use in response body for Filter Hooks.
|
||||
|
||||
## Webhook
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Triggered by an incoming HTTP request to: `/flows/trigger/:this-webhook-trigger-id`.
|
||||
Triggered by on an incoming HTTP request to:\
|
||||
`DIRECTUS-PROJECT-URL/flows/trigger/:this-webhook-trigger-id`.
|
||||
|
||||
- **Method** — Choose GET or POST from the dropdown.
|
||||
- **Asynchronous** — Toggle whether or not the Trigger responds asynchronously.
|
||||
- **Response Body** — Select data to return in the webhook response.
|
||||
- **Response Body** — Selects data to return in the webhook response.
|
||||
|
||||
## Schedule
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
This Trigger allows you to create Data at scheduled intervals, with a 6-point cron job.
|
||||
This Trigger allows you to create Data at scheduled intervals, set with a 6-point cron job syntax.
|
||||
|
||||
- **Interval** — Set the cron interval to schedule Trigger with.
|
||||
- **Interval** — Sets the cron interval to schedule Trigger with.
|
||||
|
||||
## Another Flow
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
This Trigger is triggered by a [Trigger Flow](/configuration/flows/operations/#another-flow) Operation, for chaining.
|
||||
This Trigger is triggered by a [Trigger Flow](/configuration/flows/operations/#another-flow) Operation in another flow,
|
||||
for chaining.
|
||||
|
||||
- **Response Body** — Select data to return in the response to Trigger Flow.
|
||||
- **Response Body** — Selects data to return in the response to Trigger Flow.
|
||||
|
||||
## Manual
|
||||
|
||||

|
||||
<video autoplay muted loop controls title="">
|
||||
<source src="https://cdn.directus.io/" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
Triggers on manual click of a button. Based on your configuration, a **Flows** menu will appear in the Sidebar of the
|
||||
Collection Page and/or Item Page. This will contain a button which starts the Flow when clicked.
|
||||
|
||||
Reference in New Issue
Block a user