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

When you package rules for deployment, you select the target platform. Corticon will generate a JavaScript bundle with your rules and a wrapper specific to the target platform. The available target platforms are:
  • 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.

Note: See the Corticon.js Supported Platforms Matrix to review the supported JavaScript and web platforms, and mobile apps. You are not limited to these JavaScript platforms. The API for integrating rules in your JavaScript application allows you to develop your own wrapper or integration code that calls rules.
To create a Corticon JavaScript package:
  1. In Corticon.js Studio, select a project, and then select Project > Package Rules for Deployment. The Package Rules for Deployment dialog box opens:


  2. Select the Ruleflow for your application.
  3. Choose the Target Platform:


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


  7. 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
  8. 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.
Note: When evaluating Corticon.js, every Decision Service that you package has an embedded expiration date based on your evaluation license.

Integrate rules into applications

Rules are packaged into a self-contained JavaScript bundle, and a wrapper for the targeted platform is created.
  • 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.
Integrating rules into your own application can be done in three steps:
  1. Include the generated rule bundle.
    const decisionService = require('./decisionServiceBundle');
  2. Get the JavaScript Object Notation (JSON) payload from your application.
    payload = application.getPayload();
  3. 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.