Flow Trigger
In this article we are going to analyze the Flow Trigger block.
The “Trigger” block is the only existing building block in all flows.
It is essential for the configuration of flows as it determines under what conditions a flow will have to be executed.
In the flow form, the trigger field can be configured to perform the associated flow in the following ways:
- Model – Created
- Model – Updated
- Model – Created or Updated
- Model – Deleted
- Cron
- API
Below we will analyze the possible macro configurations for the trigger field:
MODEL – CREATED
If the trigger block is configured in Model – Created, the associated flow will be executed when a Deepser entity, specified in the “Model” field as in the figure below, is created (e.g., when creating a ticket).
It will also be possible to define more specific conditions for the entity that will be created in order to perform the associated flow.
For example, let’s say we want to perform a flow when creating an “incident” type ticket, to do so we will have to configure the field in this way:
At this point you will need to click the Save button in the “Trigger” block to save the block itself.
MODEL – UPDATED
If the trigger block is configured in Model – Updated, the associated flow will be executed when a Deepser entity, specified in the “Model” field as in the figure below, is modified.
It will also be possible to define more specific conditions for the entity that will have to be modified in order to perform the associated flow.
It will also be possible to define whether the flow associated with the trigger should be executed only once or more using the “Run Trigger” field:
Below is a list of the values that this field can take on and their meaning:
- Once For Model, in this case the associated flow will only be executed once for each entity.
- Only If Not Currently Waiting on Model, in this case the associated flow will be executed only if the associated flow is not currently awaiting approval on the same entity.
- Always, in this case the associated flow will be executed each time the associated entity is updated.
For example, let’s say we want to perform a flow when modifying an “incident” type ticket, to do so we will have to configure the field in this way:
At this point you will need to click the Save button in the “Trigger” block to save the block itself.
MODEL – CREATED OR UPDATED
If configured in Model – Created or Updated trigger, the associated flow will be executed when a Deepser entity, specified in the “Model” field as in the figure below, is created or modified.
It will also be possible to define more specific conditions for the entity that will have to be modified in order to perform the associated flow.
It will also be possible to define whether the flow associated with the trigger should be executed only once or more using the “Run Trigger” field:
Below is a list of the values that this field can take on and their meaning:
- Once For Model, in this case the associated flow will only be executed once for each entity.
- Only If Not Currently Waiting on Model, in this case the associated flow will be executed only if the associated flow is not currently awaiting approval on the same entity.
- Always, in this case the associated flow will be executed each time the associated entity is updated.
For example, let’s say we want to perform a flow when creating or modifying an “incident” type ticket, to do so we will have to configure the field in this way:
At this point you will need to click the Save button in the “Trigger” block to save the block itself.
MODEL – DELETED
If configured in Model – Deleted trigger, the associated flow will be executed when a Deepser entity, specified in the “Model” field as in the figure below, is deleted.
It will also be possible to define more specific conditions for the entity that will have to be modified in order to perform the associated flow.
Below is a list of the values that this field can take on and their meaning:
- Once For Model, in this case the associated flow will only be executed once for each entity.
- Only If Not Currently Waiting on Model, in this case the associated flow will be executed only if the associated flow is not currently awaiting approval on the same entity.
- Always, in this case the associated flow will be executed each time the associated entity is updated.
For example, let’s say we want to perform a flow when eliminating an “incident” type ticket, to do so we will have to configure the field in this way:
At this point you will need to click the Save button in the “Trigger” block to save the block itself.
CRON
If the trigger is configured in Cron, the associated flow will be executed at a time interval established by the cron expression.
For example, let’s say we want to run a flow every 5 minutes, to do so we will have to configure the field like this:
At this point, you will need to click the Save button in the “Trigger” block to save the block itself.
API
If the Trigger block is configured as an “API” type, the associated flow will be executed when an API call is made on its endpoint URL.
You can obtain the endpoint URL after the saving of the flow. Clicking on it you can copy all the URLs.
In the “API Trigger” block, you can also configure as many inputs and outputs as you want.
As an input parameter, you can pass the following types: String, Integer, Array, or Attachment.
As an output parameter, you can configure the flow to obtain the following types: String, Integer, Decimal, Datetime, Boolean, Array, a single model, or an entire collection.
You can act on the usability of the created flow by configuring the following fields:
FIELD |
DESCRIPTION |
Enable Group |
With this field, you can use the flow to a specific group. |
Enable Group |
With this field, you can enable using of the flow to a specific user. |
Enable End User |
With this flag, you can enable using of the flow to the end-users. |
You can make different HTTP request methods using this trigger type of API, such as post, get, delete, and put.
API Flow Trigger – Example
On this page we will explain how to setup a Flow with an API Trigger for a CRM Account creation on Deepser.
For example, when trying to make a post request, to create a record, you have to give all the inputs provided in the API trigger block, to the request Body.
Also, the names of the inputs should match:
{
"name":"My Company Example",
"website":"www.deepser.com",
"phone": "000 111 2222"
}
For the model to be created you must add an action of type “Create Record” and give as a rule expression all the values from the request body.
To get the output you need from the API, choose the logical block “Assign values to API Outputs”. The output types that you give on this block should be the same as the types on the Trigger.
The output is returned as a JSON object from the response and it contains all the outputs that you define in the Trigger section (in our case, the “entity” section of the object) and other generic information related to the executed flow (“context” section of the object).
{
"output": {
"result": {
"name": "My Company Example",
"website": "www.deepser.com",
"phone": "000 111 2222",
"created_at": "2024-07-10 12:37:14",
"created_by": "admin",
"current_version": 1,
"updated_by": "admin",
"company_id": 0,
"updated_at": "2024-07-10 12:37:14",
"entity_id": 6
}
},
"context": {
"status": 3,
"depth": 1,
"flow_header_id": 1,
"flow_id": 15,
"source": "trigger",
"created_at": "2024-07-10 12:37:14",
"updated_at": "2024-07-10 12:37:14",
"entity_id": 31,
"current_node_id": 1,
"status_label": "Completed"
}
}