Adding a Conditional Step in a Digital Process
Build upon and improve the created digital process.
Last updated
Was this helpful?
Build upon and improve the created digital process.
Last updated
Was this helpful?
Having the first Hello World digital process set up, we can now add conditional logic to the way it works. The condition would include sending an additional email notification, but only if a sender provides us with a specific response to a form. To use conditional logic and add a condition step with a decision rule in the Hello World digital process, we will first prepare a new Make scenario and then create a business rule in OE Rulestore.
Similar to the Setting up a First Digital Process, we will create a scenario named Send Outreach on Mixed Feedback that sends another email to forms recipients.
To build the scenario:
Go to OE -> Events -> Event Registry and create a new hello_outreach_sent
event named Hello World Outreach Sent.
Go to Digital Processes and open the Hello World process that you created in the first trail.
Add a new process step and choose to Create New Scenario. This directs you to a Make scenario template.
As a first step of the Make scenario, establish the connection in the Trigger Event module.
Add the Set Variable from Process Context module and configure it with the following details:
Assign the Data from the Trigger Event.
Select the Hello World digital process.
Use the Instance ID from as the Example Instance. You can select the ID from the drop-down list. The ID at the top is the one from the latest instance.
Choose Hello World Feedback Sent as an Event Type.
Choose email
from the Field drop-down list.
Type email
in the Variable Name field.
Add the second Set Variable from Process Context module and configure it with the following details:
Assign the Data from the Trigger Event.
Select the Hello World digital process.
Use the latest Instance ID as the Example Instance. You can select the ID from the drop-down list. The ID at the top is the one from the latest instance.
Choose Hello World Feedback Provided as an Event Type.
Choose forms.0.payload.firstName
in the Field drop-down list.
Type firstName
in the Variable Name field.
Choose Yes for Raise Error when Null.
Add the Mailgun (Send an Email) module. We use Mailgun as the exemple email provider as in the Setting up a First Digital Process trail. Ensure you allowlist the email recipient in your Mailgun account, so that the email gets sent. To make the module work, you need to set it up as described in documentation. Use the following Mailgun module configuration:
Choose a specific email address as the Type of recipient.
Enter the email address of the recipient in the To -> Add items list.
Add the sender email address.
Add the subject of the message and insert the text that you want to send.
In the Completion Event, choose the Hello World Outreach Sent event as the Event Type.
Save the scenario and choose Run once.
Go to OE and open the Hello World digital process. Add a new process step with the new scenario, you can see that the Send Outreach on Mixed Feedback scenario is now visible in the available scenarios list. Choose the scenario as the process step.
Choose Publish and then ensure that the digital process is active.
Ensure that the Send a Survey on Hello World and Send Outreach on Mixed Feedback scenarios in Make are active as well.
To test, re-run the new instance of the digital process by sending a new trigger event. You can send the same event using the Postman request, or Celonis action flows, that you used in the Setting up a First Digital Process trail to start the digital process.
After sending the event, first you get an email requesting you to submit a response to the created form. And then, after submitting the response, you get a second email with a Thank You message.
Up to this point the Send Outreach on Mixed Feedback scenario was invoked by any response submitted by the form recipient. Now, we will limit this process to invoke the scenario only on indifferent
or sad
responses. To do that, we first need to create a business rule and then apply it in the Hello World digital process as a decision on a process step.
Emporix Orchestration Engine provides a Rulestore that allows to manage business rules outside of the digital processes and Make scenarios. The rules can be expressed with JsonLogic. Using JsonLogic, we will create a rule that identifies sentiment responses that need further outreach.
To create a new rule:
In Management Dashboard, go to OE -> Rulestore and choose Create rule.
Choose if you want to create the rule in Simple or Advanced mode.
If you choose the Simple mode, add the following values in the blocks:
Name: Sentiment Requiring Outreach
Description: for example - measure how positive recipients are
Unit: list
Expression: in
Value: indifferent
, sad
If you choose the Advanced mode, add the following:
Name: Sentiment Requiring Outreach
Rule Expression: add a JsonLogic expression that evaluates to true
if a variable called sentiment
has indifferent
or sad
values. The editor validates the expression syntax, so it's possible to save only the valid forms:
Save the rule. It's now visible in the Rulestore list.
Copy the rule's ID, it will be used in the next steps.
When we have the business rule created in a Rulestore, we can now use it as a condition for a process step in the Hello World digital process.
To apply the business rule:
Go to the Hello World digital process and in the Send Outreach on Mixed Feedback process step choose Add logic.
Go to the Decision tab. Here, you can see the JSON Logic Expression field, where you can insert the business rule that you had prepared for the process step.
Enter the following expression, with your business rule ID:
The businessRule
is a JsonLogic operator that refers back to the rule managed in the Rulestore.
The first part is the rule ID that you have to copy from the Rulestore and then paste in the expression.
The second part maps the rule variables to the actual relevant fields in your process context. Here, we are saying that the sentiment field can be found in the hello_feedback_provided.forms.0.payload.sentiment context event field.
Choose OK to save the expression as the process step decision.
Publish the new version of the digital process and ensure it's active. Now, only the responses with indifferent or sad values result in running the Send Outreach on Mixed Feedback.
However, the digital process completes regardless of the response that is submitted in the form.
Send the event request again by Postman or Celonis action flows. As a result, you receive a submission form request again.
In the first form submission provide the answer as happy. This will not execute the Send Outreach on Mixed Feedback process step.
If you provide the response as indifferent or sad the Send Outreach on Mixed Feedback is invoked and you receive another email with the Thank You form and information about the next steps that you included in the text.
You can also use the debugger mode to verify if the digital process works properly. Go the Hello World digital process and choose the magnifier icon to open the debug mode.
If the response is happy, you can see that the step was filtered.
If the response was indifferent or sad, the step was invoked.
It is also possible to use events themselves as conditions on process steps. Multiple events can be assigned to a step or group of steps, and both IN (OR)
and AND
operators are supported. It's a preferred option when it is simply enough to test the presence of an event.
To learn more about the conditional logic in OE, see the documentation.
To learn more about JsonLogic and get some examples, see the and websites.