A knowledge base can be deployed to run in Silent mode (without user interface) on a Node.js instance listening on a particular port. For example when a knowledge base (in this case the Expenses sample) is deployed a unique URL is returned which should then be used to trigger the execution of the knowledge base.
https://xrkb.xpertrule.com:8125/1LzxsurLnFz7Jy3L
The data to be passed to the URL should be via an HTTP POST method with the format of the expected input data in JSON format. The inputs and outputs are defined in the 'Input & Outputs' item on the Knowledge Base Settings menu before deployment.
{
"Cost": 0,
"Department": "Accounts",
"Grade": "Director",
"In_London": true,
"Services": [
"Room",
"Meals"
]
}
{
"state": "END",
"Claims": "Pay",
"Expenses": "Pass"
}
The knowledge base is available as a REST based web service. There follows some sample code (implemented in PHP/cURL) for calling a deployed knowledge base...
<?php
$xrServer = "https://xrkb.xpertrule.com:8125/1LzxsurLnFz7Jy3L";
$input= '{
"Cost": 75,
"Department": "Accounts",
"Grade": "Director",
"In_London": true,
"Services": [
"Room",
"Meals"
]
}';
echo $input;
// Call XRserver...
$ch = curl_init($xrServer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
$output = curl_exec($ch);
echo $output;
?>