Fluent Commerce Logo
Docs

Learning - Workflow Framework Rules and Rulesets

Essential knowledge

Changed on:

1 Nov 2024

Overview

[Warning: empty required content area]

Key points

[Warning: empty required content area]
To fuel your business, you need business logic.  But what makes business logic in Fluent Order management?  ...It's the rules and rulesets
What is a rule?
Rule represents a single piece of business logic that can be configured and reused. Rules:
  • have a single purpose.
  • produce a single Action.
  • the outcome is always an action  such as sending a new Event or updating data on an Entity
  • are combined together to form a Ruleset.
A Useful AnalogyA rule is like a Lego block. Each Lego block comes in different shapes and sizes but can be used in a variety of scenarios, and to deliver multiple different results.  By composing multiple different Lego blocks together, you create different structures. Similarly, composing multiple different rules together into rulesets produces different logic and behavior.Fluent Frame of Reference: Some examples of rules in Fluent Order Management : 
  • Change the state of an Entity
  • Send an email
  • Fulfill Order from the Collection point
  • Send a new Event
Any changes to be made as a result of running a Rule by the Orchestration engine are returned in the form of an Action.No alt provided
What is a Rulseset?
Ruleset is a collection of one or more Rules which get executed upon receiving a matching trigger via an EventRulesets are a combination of rules used to deliver a piece of business logic. The execution of a Ruleset can transition the entity through the lifecycle by changing its state, or it may just result in non-transitional actions, such as sending an email to a customer.The contract to trigger an event requires the trigger states, rule parameters, and attributes.All the rules defined in the Ruleset execute in sequence.  
  • Rule/rulesets can have outcomes as Actions. 
  • Rulesets can also have User Actions configured. 
Actions and user actions
An Action represents an outcome of a Rule. Actions from rules executed are applied at the end of the event execution.Listed below are some of the action examples:
  • Creating a new Event
  • Creating or updating an Entity
  • Triggering a third-party action.  E.g. Sending an email or posting a webhook request.
User Actions are the mechanism by which user interactions can be integrated with workflows from Fluent Web Apps. No alt provided
Single ruleA Rule represents an atomic business logic that can be configured and reused.
Rule 1-Example 1An example of a single rule: "Send an email " which represents one use case in the business.
Rule 2-Example 2Another example could be a rule to change the State of Order from booked to fulfilled.
Rule 4 – Example 3You can have rule to send an event, like the " OrderFulfil" event for the Order entity.
RulesetRulesets are a combination of rules to deliver a piece of business logic.
Ruleset Example 1We can configure Rule1, Rule 2, and Rule 4 together to accomplish the goal of sending order fulfillment events for the Order entity as well as to send an email about confirmation of state changed.
Ruleset Example 2Similarly, we can reuse and configure rules 1, 3,4 and add more rules to make another rulesetYou can configure one rule multiple times in the same ruleset.
In this lesson, you learned about Rules and Rulesets. Let's jump into the next lesson to learn more about the Workflow Builder and also learn how to create a Ruleset