Execution flow details
The section goes into the details of what causes the automation to execute, the important steps of the execution flow, and what happens with the result of the automation. A simplified explanation is described here.
Implicit automation
An automation is considered implicit, if the trigger uses a before
, or an after
event; for example beforeCreate
and afterCreate
.
Implicit automation is automatically executed whenever we interact with specific resources, such as records or users.
The two variations of events (before
and after
) follow the same path, with the difference in when the event is dispatched, and how the resulting value is used.
before
events are dispatched first and their execution result may affect the rest of the execution, while the after
events are dispatched after and the execution result does not affect the rest of the execution.
A component receives a request to interact with a resource. |
For example; we wish to create a new record, or update the email of a user. |
||
Access control checks if the invoker is allowed to perform the operation. |
If the invoker is not allowed to perform the operation, the request is rejected and no automation is executed. |
||
Content sanitization and validation prepare and validate the data. |
Before any destructive operation occurs and before the |
||
The |
If the automation is synchronous, the operation awaits for the dispatched event to resolve before continuing the initial operation. If the automation is asynchronous, the initial operation does not await. The resulting value of the synchronous automation affects how the initial operation should continue:
|
||
Content validation and sanitization occurs. |
Before any destructive operation occurs, the modified values are validated and sanitized.
If the validation fails, the request is rejected and the |
||
The resource is manipulated. |
The original operation completes and the change is permanently written to the store. |
||
The |
The operation does not await for the event to resolve and the result of the automation is therefore ignored.
|
Explicit automation
An automation is considered explicit, if the trigger uses an onManual
event for any resource.
In some cases, you can use explicit automation to replace the need for sink routes. DevNote add some documentation regarding the above statement. |
Explicit automation is executed when manually invoked. On the front-end this is usually done with a button press, but under-the-hood, this is just an HTTP request to an API endpoint.
Automation scripts and workflows define separate API endpoints to invoke explicit automation. For automation script this is a For workflows this is a |
A component receives a request to execute an automation. |
For example; a CRM user pressed the button to send an email message, or to initiate an outbound phone call. |
||
(Workflow specific) The RBAC facility checks if the invoker is allowed to execute the automation. |
If the invoker is not allowed to execute the workflow, the request is rejected.
|
||
The automation is executed and the results are returned as a standard HTTP response. |
The results provide the output of the automation, along with some metadata such as execution stack traces and error messages. |
Deferred automation
An automation is considered deferred, if the trigger uses an onInterval
on an onTimestamp
event.
Deferred automation is invoked by the system based on the provided temporal information. The execution is not tied to an operation (such as a manual invocation or an event).
Under-the-hood, Corteza defines a ticker, that dispatches onInterval
and onTimestamp
events once every minute (can be configured via EVENTBUS_SCHEDULER_INTERVAL
.env
variable).
The dispatched events are then used to match and invoke any automation with conforming triggers.
Corteza dispatches interval and timestamp events for the system and compose components. Internally, these events are the same, but are kept for legacy reasons. |
Deferred automation requires you to explicitly set the invoking user as the automation is executed by the system and we are unable to determine the invoking user. |
The system ticker dispatches an |
The events are dispatched on the eventbus. |
The automation is executed asynchronously and the results are ignored. |
The execution value of the automation does not affect any other automation. |
Sink automation
An automation is considered sink, if the trigger is bound to the System Sink
resource.
A sink automation is executed when the system component receives an HTTP request to the /sink
API endpoint.
The execution is not tied to an operation (such as a manual invocation or an event).
Sink automation requires you to explicitly set the invoking user as the automation is executed by an external user and we are unable to determine the invoking user. |
The system component receives an HTTP request to the |
For example; Refer to the DevOps guide/sink routes for setup details. |
||
The signature is validated |
Firstly the sink signature is validated to make sure it was not altered.
|
||
The signature is used to validate the request. |
The system validates the protocol, headers, origin, and other signature constraints. |
||
The |
If the automation is synchronous, the operation awaits for the dispatched event to resolve before continuing the initial operation. If the automation is asynchronous, the initial operation does not await. The resulting value of the synchronous automation affects how the server should respond:
|