Package rules with Corticon.js
- Last Updated: January 8, 2025
- 4 minute read
- Corticon.js
- Version 2.3
- Documentation
After the rules are tested, you package the rules for deployment to any of the supported JavaScript platforms. Packaging rules is easy.
How to package rules for JavaScript deployment
- AWS Lambda
- Azure Functions
- Google Cloud Functions
- Browser
- Node.js
Selecting AWS Lambda, Azure Functions, or Google Cloud Functions as the target platform generates the rules and a wrapper ready for deployment as a serverless function. After the rules are deployed, you can use them on your cloud platform—for example, to expose the decision service through a REST endpoint, to respond to a database update, or to integrate into a cloud vendor workflow system such as AWS step functions.
The Node.js target can be used for running decision services in Node server and as well to run them in Mobile applications created with NativeScript and ReactNative.
Selecting Browser generates the decision service and simple example code that demonstrates how to integrate the rules into your application.
- In Corticon.js Studio, select a project, and then select
. The dialog box opens:

- Select the Ruleflow for your application.
- Choose the Target Platform:

- Enter a preferred Bundle name so that you produce your package in a distinctly named folder. Each Ruleflow selected generates a separate package.
- Enter a preferred to Directory where your package will be placed.
- Click Next. The second panel of the
dialog opens:

- Choose the top-level entities for this package. In our example,
only the Cargo entity is referenced so just that entity is selected. The top-level
entities are entities that will be expected (and required) in payloads executing
the decision service. You could choose all entities or none, but that will mean
that the decision service will have to evaluate each entity, which might be a lot
of wasted cycles. Note: For more information, see JSON payloads and results in Corticon.js
- Click Finish to generate the packaged JavaScript as a Decision Service plus everything you need to deploy it. The packaging process generates a single JavaScript bundle that is the entry point for the rules, which contain all the decision logic in its enclosed components for the selected Ruleflow. The generated bundle is compressed and obfuscated. It is valid, executable JavaScript, but it is not readable and cannot be edited.
Integrate rules into applications
- For AWS Lambda, Google Cloud Functions, and Azure Functions, the wrapper is ready to be deployed as a serverless function to the cloud. After the wrapper is deployed, you can make it accessible as a REST service, or integrate it into a cloud workflow.
- For Browser and Node, the wrapper provides an example of the code to integrate the rules into your own application.
- Include the generated rule bundle.
const decisionService = require('./decisionServiceBundle'); - Get the JavaScript Object Notation (JSON) payload from your
application.
payload = application.getPayload(); - Execute the rules on the payload.
result = await decisionService.execute(payload);
The payload is a JSON document mapped to your rule vocabulary representing a loan application, benefits claim, vehicle configuration, or other business object required to make a decision.
The result returned is a JSON document including the input payload and any decisions made by the rules such as a risk rating, claim approval, vehicle quote, or other attributes set by the rules when processing the payload.