Overview: This blog outlines implementation details of OpenRules Decision Manager.
Target Audience: Engineering
Problem Statement: Oftentimes, in CRM systems, the status/stage of Lead, Opportunity or other should drive the assessments to be presented, information to be captured, etc. As an example, how can we present Assessment 1 if Lead.Status=Unqualified or Assessment if Lead.Status=Qualified etc. Now, how can we make the logic dynamic so that nothing is hardwired in the CRM platform of choice? In addition, how can we launch it as a micro-service on AWS platform so that there is only a marginal cost per the decision taken and no cost when there is no decision taken.
OpenRules Decision Manager(ODM).
This OpenRules Decision Manager is the SaaS-based rule engine that is available in the AWSMarket Place. OpenRules Decision Manager is available on-premise or on the cloud as the first AWS SaaS Rule Engine. We at Focal found ODM to be highly scalable and super-fast allowing decision services to:
- Startup in almost no time.
- Be executed within milliseconds.
- Require only a minimal memory footprint.
Components in OpenRules Decision Manager
- Create Business Decision Models with Excel and OpenRules templates for representation of the sophisticated decision logic.
- Test/Debug/Execute/Analyze Decision Models with OpenRules engines
- Deploy Decision Models as decision services on-cloud or on-premises.
They can be naturally deployed as containerized decision services using AWS Lambdas, RESTful Web Services, Docker, Kubernetes on the cloud frameworks provided by major cloud vendors such as Amazon, Google, Microsoft, and IBM. We love OpenRules Decision Manager and hope this blog helps other Engineers appreciate the power of ODM and give some guidance on implementation. Over the last few years or so, we have done significant analysis and have come up with series of steps to create your own decision model and deploy as Lambda.
Sample Use case:
In my sample project, my goal as Rules Engineer is to delver a decision service to our StoryPulse (product) team that can take LEAD.STATUS as inputs and deliver the right Assessment and Content for that Lead in real-time.
Below are the high level steps
1) Download the OpenRules Decision Manager from AWS Marketplace.
2) Setup the Open Rules Decision Manager in local Machine.
3) Create the custom openRules Decision Manager project.
4) Convert the decision rule into AWS Lambda and deploy.
Step 1 : Download Decision Manager:
- Java Development Kit, version 1.8 or higher.
- MS Excel or Google Sheets (for rules creating/editing only)
Download OpenRules Decision Manager from AWS Marketplace.
Once you click on the AWS Marketplace, it launches the login screen needs to authenticate with AWS credentials.
After signing into the AWS Marketplace account, you can see the below screen. Click on the button “Continue to Subscribe” from this AWS Marketplace website:
After clicking on “Subscribe”, you will see:
Click on “Set Up Your Account” and you will be asked to register:
You will need to Sign up with your email address and password. After an email confirmation (if it is your first registration), you will see the download view.
Once you click on “Download”. You will receive a personalized version of the latest OpenRules Decision Manager in one zip file “OpenRulesDecisionManager_8.1.x.zip” that you unzip on your hard drive.
You will get the folder “openrules.samples” that contains everything you need to learn about how OpenRules decision models are organized, how to build, test, and deploy them, and finally how to develop your own operational decision models.
Step 2 : Setup the OpenRules Decision Manager
To install the latest OpenRules Decision Manager on your computer, you need to execute “install.bat” from “openrules.samples/openrules.config” – just double-click on this file from your File Manager.
Once you click on the “install.bat” openRules Decision Manager will download all the maven dependencies and store them in the local maven repository.
There should be no red messages and the successful installation will show at the end.
Step 3: New Custom Project Creation
“OpenRulesDecisionManager_8.1.x.zip” that unzip on your hard drive. You will get the folder “openrules.samples”.
Click on the “openrules.samples”
You can see the list of sample evaluation projects. Along with the sample project, you can see on of the key component “openrules.config”
By clicking on the “openrules. config” you can find the .bat files .
Click on the “createProject.bat”
Once click on the createProject.bat
A popup shell window comes asks for the project name.
As an example, I have given the project name as “LeadStatusAssessmentRule”
Now we can see the newly created project “LeadStatusAssessmentRule” along with the sample evaluation projects.
Go inside the new project you can see the below files.
Click on the rules folder you can see the below files.
By default, in the Rules.xls,Glossary.xls has “Hello statement” rules and a glossary object.
Need to customize the rules and glossary according to our requirement.
In my sample project, our goal is to make decision to fetch the assessment details and content details associated with the particular lead status.
Based on this requirement Rules.xls, and Glossary.xls would look like below.
Need to change the Test.xls as per the rule defined and the test data would be prepared based on our custom Glossary object.
To analyze and test the rule what we have defined added below test data.
Once test data is ready need to run the sample project to check whether it would be passing the test case scenarios.
To run the project, click on the “build.bat”.
Once the project builds successfully without any exceptions
Run the command “run.bat”.
You can see the test cases execution in the command shell, if all the test cases are executed without any exceptions then only “OpenRules Decision Manager” takes an Excel-based business decision model and converts it into highly efficient Java classes.
Step 4: Convert the decision rule into AWS Lambda and deploy
To deploy this sample decision model on AWS lambda, need to perform the following steps.
Configure the AWS keys in the project.properties file.
package.name= package name (you can give the package name all the automatically generated class will point to this package when run build.bat)
aws.lambda.bucket=S3 bucket to store the Lambda zip file
Place the “deployLambda.bat” file in the source folder.
When we download the openrules decision manager they have given one sample project to understand the process how to deploy decision model to Lambda.
Copy the “DeployLambda.bat” from the same evaluation project (VacationDaysLambda) and place in our custom project source folder.
Now click on the deployLambda.bat file on our custom project source folder.
It will open the windows command shell and execute the test cases and generate the source zip file and upload in the S3 bucket of the configured AWS account.
Once lambda is deployed it will automatically add the API gate and provide one endpoint URL.
By using that endpoint URL, any mobile device or third-party application will access the lambda, based on the input request the decision model executes and result is given back as JSON output.
We can test the lambda with any one of the browser rest-client plugins.
Testing the Endpoint URL: Lambda API rule from the above screenshot.
In this example explaining how to test the deployed Lambda using the “Postman rest client”
Request Method: Post
Request Type: JSON (application/json)
“status” : “Prospect/Opportunity”
Now, my StoryPulse (product) team is ready to consume this and display the right assessment to the right Lead at the right time. The rules can be easily changed later on as needed without writing a single line of code.