Triggers
Last updated
Last updated
In this video, we will walk through everything you need to know about “Triggers and State Manager” in Easyflow.
Let’s first create a new flow with the title “Triggers and State Manager”.
A trigger is a mechanism that allows a workflow to be executed in response to an event. For example, a workflow can be triggered when a new email is received.
To demonstrate this scenario, we will configure the Receive Emails built-in connector and set it as a starting point. After saving the configuration, run the workflow by previewing the results.
The last 5 emails were returned as expected and aligned with the connector configuration.
Let's try to run the workflow a second time. We'll notice that no data has been returned, because no new email has been received since the last call.
By examining the State Manager in the connector configuration, we observe that it retains the date value of the last received email. This means that the workflow will get triggered to return only the emails received after this date.
Let’s send a new email and re-run the workflow to see the outcome. As we can see, the workflow received the last email.
By running the workflow again, as expected there are no emails returned because there have been no new emails received.
In addition, we can see that the state manager is persisting the date value of the last received email.
In the next example, we'll demonstrate how to configure custom triggers using the State Manager settings.
In this example, we will explore two scenarios: First, without having the state manager enabled. Second, by enabling the state manager.
Let's begin by configuring a new built-in connector for receiving emails. To do this, select the Receive Emails option from the operations panel.
This option does not have state management enabled by default. Accordingly, we expected that all the last 5 emails would be returned every time we executed the workflow.
Let's save our changes and set this step as the initial starting point before running the workflow.
As a result of our test, we can see that 5 emails were returned. Also, when we ran the workflow a second time, the same 5 emails were returned. This indicates that the workflow is not storing the last received email as we saw in our previous example.
Before continuing, configure and enable the state manager. To do this, follow these steps:
Enable the state manager's checkbox.
In the Key text box, enter the JSON path to the unique field that will be used as a flag to persist the state. Consider using the Star sign when pointing to an item within an array.
In the Start Value section, you can leave it blank.
Make sure to save your changes before running the workflow.
As you can see from the results, the last emails will be returned in the first run, while no emails will be returned in the second run.
The workflow will behave exactly as a trigger when enabling and setting up the State Manager.
Thank you for watching this video.
Please feel free to contact us if you have any questions.