Deploy your Rule
Authors:
Ankit Mehta, Cille Schliebitz, Anita Gu
Changed on:
4 Feb 2025
Overview
In this lesson, you will learn how to deploy and run a custom rule.
Key points
- Access to Fluent Training account is required
Deploy your Rule
In the previous module, you tested the Rule which you created for the client. Now, we will deploy the fully tested Rule into the Workflow.
The following steps need to be performed to deploy and run your custom rule:
- Prepare your plugin for deployment
- Upload and install your plugin on your account
- Add your new rule to a ruleset within a workflow
- Execute your new rule
- Complete your new Workflow
- View the audit events for your rule execution
Step 1 - Prepare your plugin for deployment
Compile & Package
Before a plugin can be deployed to production, it needs to be compiled and packaged by completing the following steps:
1. Test - Run all unit tests to ensure your plugin is ready.
2. Version - Make sure to prepare the version for your plugin in the pom.xml file and build the project (maven clean package).
3. Jar file - Maven clean on the plugin project will produce a Java Library (.jar) file, which can be uploaded and installed onto a sandbox environment (before being deployed to a production environment).
Important
- A particular plugin version can only be uploaded once.
- Inside pom.xml version tag , SNAPSHOT is possible but can be confusing since “-“ gets replaced with “." which can impact on GET. We recommend replacing SNAPSHOT with version like 0.0.1
- All the test cases need to Pass else the maven built will fail and won't generate .jar file.
👁🗨 Video Demonstrating Step 1: Prepare your plugin for deployment
This video illustrates how to:
✅ Manage the version of your plugin ✅ Generate a jar file for your plugin
Step 2 - Upload & Activate
Once you have prepared your plugin for deployment, next you have to upload the plugin into your Postman account. Follow the steps to upload and activate your plugin:
Postman & Account Authentication
- Navigate to the DV-RS-01 Deploy a Custom Plugin > Authenticate Account Super User in the Fluent Learning - DV-RS1 Labs Postman collection.
- Select the Fluent Auth request, and click Send. This will authenticate the Super User who has the right to deploy on the account.
* The Postman environment variable called access_token will be set on successful authentication. This access_token will be used in the following API requests.
Upload Plugin
- Navigate to the DV-RS-01 Deploy a Custom Plugin > Deploy & Validate > Upload plugin and POST the request.
- Set the file parameter in the body of the request by selecting your plugin jar file. On the Body tab, click on Select Files, then browse to locate your plugin jar file.
- Click Send to upload your plugin. Confirm that you receive a successful response, HTTP Status Code 200 OK.
Activate Plugin
- Navigate to Deploy a Custom Plugin > Deploy & Validate > Activate plugin and POST request.
- Click Send and confirm that the response is 200 OK.
Note: This request does not contain a response body. - Inside Deploy & Validate run Plugin Status & Account Rules GET Requests. These requests will give you details of all the active Rules in your account (e.g. event, parameters, event attributes) which are used as the environment variables.
- Use the Get Plugin Status request to confirm that you have successfully uploaded and activated the plugin. The response should contain a field called bundleStatus with a value of ACTIVE.
- Now that your plugin is successfully activated, use the Get Account Rules request to see all the rules active in the account. Search the response for the name of your rule MarkOrderHighValueRule.
💡 Refer to the diagram below for help with uploading and activating your plugin.

- Upload Plugin - It's a Post request where you will upload your plugin and send the request.
- Plugin Status & Account Rules - These GET request will provide you with your details of your active Rule like parameters, events , event's attributes. These details are used as environment variables.
- Activate Plugin - This Post request Activate your uploaded plugin.
- File - Use File as the Key value.
- Upload's plugin request - Body - You will upload the plugin in the Body of Upload Plugin Request.
- Successful upload - On successful upload you should get status 200 OK response.
- Choose jar file - Browse to location of your plugin project. It is a Jar file which you have created in the Step1 - Prepare your plugin.
- Send request - Once you have uploaded the plugin , Send the request.
👁🗨 Video Demonstrating Step 2: Upload and activate your plugin
This video illustrates how to:
✅ Authenticate on the Postman ✅ Upload and activate your plugin
Step 3 - Add your New Rule in the Workflow
- Login to your Fluent Console using your FC_Fashion retailer credentials.
- Authenticate FC_Fashion Retailer in Postman. A successful request will generate a valid access_token and status 200 OK response.
- In Postman, navigate to DV-RS-02 Apply Simple ORDER: CC Workflow and execute the Simple ORDER:: CC Workflow PUT request. A Click and Collect (CC) Workflow will now appear on your Console.
* Refer to the image below showing an updated CC Workflow on the Workflow Editor.

👁🗨 Video Demonstrating Step 3: Add your rule in the workflow
This video illustrates how to:
✅ Add your rule in the Workflow
- Open the newly updated Order CC Workflow in the Modeller.
- Click ADD RULESET, create a new RULESET and name it AnnotateOrder. *See table below for an e.g. of a short and meaningful description of a Rule.
- Save your RULESET. This will open the RULESET editor drawer that will prompt you for details of the Rule. Refer to the below table to fill in the required details for the Rule:
Field | Value |
Description | This can be a short and meaningful description of the Rule |
Available from |
|
Rules | Rules will provide all the active Rules in your account. You can add one or more Rules in a RULESET. |
- Commit changes.
💡 Let's have a look at the Workflow Editor to add a rule in the RULESET

- Active Rules - This list is displayed when you pick Rules. The list shows all the Active Rules in your Account. You can search and select the Rule.
- Description - Write a short and meaningful description of the Ruleset.
- Available from - Select the state on which the Ruleset will be available. MarkOrderHighValueRule is available when the order is in Received state
- Rules - Add the Rules required for the RULESET. Clicking on Rules will list all the active Rules in your account.
👁🗨 Video Demonstrating Step 3: Add your rule in Workflow Editor
This video illustrates how to:
✅ Add a Rule in the Ruleset in the Workflow Editor
Step 4 - Execute your new Rule
To execute your Rule in the workflow, you need to call the rule from your current Workflow:
- Click on CREATE Ruleset and revise the current Workflow by changing the Send a MockBookOrder event for the (current entity) Rule to Send an AnnotateOrder event for the (current entity).

- Create RULESET - Click on Create to modify the current Workflow to call the added Rule
- Send an event for current entity - Call the Rule in "Send an ______event for the current entity.
Now to execute your rule, we will send an order into the system. To check the Rule's functionality completely, we will create two separate Orders:
- An Order with a total price greater than the threshold value
- An Order with a total price less than the threshold value
Order Creation Steps
Using DV-RS-03: Create orders for FraudCheck Logic in Postman, Execute:
- Create Customer POST request — this request will create a Customer.
- Create CC Order with Price 105.00 POST request — This request will create an Order with a total Price of 105.00 which is less than the Rule's Threshold value.
- Create CC Order with Price 205.00 POST request — This request will create an Order with a total Price of 105.00 which is greater than the Rule's Threshold value.
On the Fluent Console, navigate to the Orders section and locate your created Order. The Order should be in a Received State. Click on the Order to view the order details — check the following:
- Check if the attribute IS_HIGH_VALUE, has a value of True for the Order with Price 205.00
- Check there should be no Attribute called IS_HIGH_VALUE for the Order with Price 105.00. But the Order should still be progressing through the workflow.
Please authenticate FC_Fashion Retailer on a regular basis — the access_token expires after a certain period of time.
👁🗨 Video Demonstrating Step 4: Execute your Rule
This video illustrates how to:
✅ Create customers and orders ✅ Execute the order
Step 5 - Complete the fraud workflow
Execution Context
When an Orchestration Event is received by the Workflow Engine, it initiates the Execution Context. The Execution Context includes the event and the entity specified by the event. The Workflow Engine loads and locates the appropriate workflow for the given event context, based on the entity type and version.
To learn more read Understanding Event Execution.
Complete the Fraud Workflow
Once we know our MarkOrderHighValueRule works as expected, we can add an end-to-end fraud Workflow, based on high-value orders by the steps below.
Add a new RULESET named ValidateOrder with the following:
Required Rules | Rule parameters |
SendEventWhenEntityAttributeValueEquals |
|
SendEventWhenEntityAttributeValueEquals |
|
SendEventWhenEntityAttributeExistsOrNot |
|
- Description of Validate if the Order can be automatically booked or need manual intervention
- Add three (3) Rules to complete the Workflow. Refer to the table below for the details of the Rules required in the RULESET:
Modify AnnotateOrder Rule: In the AnnotateRule RULESET , add SendEventGQL Rule with ValidateOrder RULESET event. Refer to the interaction below and click on + buttons to learn about the required modifications.
Learn more about the required modifications:

- Modify AnnotateOrder RULESET - Once the ValidateOrder RULESET is created , then modify AnnotateOrder RULESET to add SendEventGQL Rule
- SendEventGQL Rule - In the SendEventGQL Rule , call the ValidateOrder event .
Complete the Modified Workflow
Execute the following using DV-RS-03: Create orders for FraudCheck Logic in Postman:
- Create CC Order with Price 105.00 POST request - This request will create an Order with total Price of 105.00 which is less than the Rule's Threshold value.
- Create CC Order with Price 205.00 POST request - This request will create an Order with total Price of 105.00 which is more than the Rule's Threshold value
- On the console, navigate to the Orders section and locate your created Order. The Order with price of 205.00 should be in FraudCheck state and Order with price of 205.00 should be in Completed state . Click on Order to view the order details.
👁🗨 Video Demonstrating Step 5: Complete the fraud workflow
This video illustrates how to:
✅ How to complete the Fraud Workflow by creating another Rule and creating a Workflow flow.
✅ Create orders to check the complete Fraud Workflow
Step 6 - View the Audit events for your Rule execution
To inspect the details of what happened during the workflow execution, you can inspect the Audit events generated. The following methods can be used to view an Order:
- Activity section within Fluent Console — Here, you will see the high-level state lifecycle that the Order went through.
- Fluent Console Events screen —Here, you can search for your Order ID, Reference, or other available filter and view the raw event data associated with the Order.
- Postman — Here, you can retrieve all the events associated with the Order in JSON format. You can execute the 'Get Order' Audit Logs GET request in DV-RS-03, create Orders for FraudCheck logic and see the details of all events associated with the Order.
Refer to the image below showing an Audit event on Order using Postman:
