Getting Started

Install RuleBox and see what it registers in WireBox.

On this page

Getting Started

Requirements

  • BoxLang 1.18+
  • ColdBox 8+

Installation

Leverage CommandBox to install RuleBox as a module in your ColdBox application. It installs into your app's modules/ folder:

box install rulebox

Optional modules

Rules written in BoxLang or JSON need nothing else. Two features rely on official BoxLang modules that RuleBox does not install for you, so install them only if you use them:

FeatureInstall
YAML rule files (YAMLRuleSource, or .yaml/.yml files in the convention folder)box install bx-yaml
Visualizer metrics that survive a restart (SQLiteMetricsStore)box install bx-sqlite, plus a datasource. See Rule Visualizer.

Your first rule

Save this as models/HelloWorld.bx:

class extends="rulebox.models.RuleBook"{
	function defineRules(){
		addRule( newRule( "greet" )
			.then( ( facts, result ) => result.setValue( "Hello " & facts.name ) ) )
	}
}

Then run it from a handler or anywhere you can call getInstance():

getInstance( "HelloWorld" )
	.run( { name: "World" } )
	.getResult()
	.getValue()

That returns Hello World. run() takes your facts, getResult() gets the result, and getValue() reads what the rule put in it. To go deeper, see Defining RuleBooks.

What gets registered

Once installed, the module registers the following objects in WireBox:

WireBox IDTypeDescription
Rule@ruleboxTransientA single rule
RuleBook@ruleboxTransientA rule book that groups and chains rules
Builder@ruleboxSingletonBuilds à la carte rules and rule books
Result@ruleboxTransientModels the result produced by a rule chain
RuleBookRegistry@ruleboxSingletonHands out named rulebooks declared in settings or config files

RuleBook and Rule are transient objects - they carry state (facts, results, audit trail) across a run(), so a fresh instance is requested every time via getInstance(). See Thread Safety for why that matters.

Next steps

Need help beyond the docs? See Help and Consulting for professional support from the Ortus Solutions team.

Edit this page Download Markdown Last updated Oct 7, 2026, 10:59:26 AM