Portal Community

Node Configuration

{
  "nodeType": "RuleEval",
  "name": "checkInvoicePolicy",
  "config": {
    "ruleSetId": "invoice-approval-policy-v2",
    "inputMap": {
      "amount": "$output.fetchInvoice.data.total",
      "currency": "$output.fetchInvoice.data.currency",
      "category": "$output.fetchInvoice.data.category",
      "vendorTier": "$output.fetchVendor.data.tier",
      "submittedBy": "$context.actorId",
      "isFirstTimeVendor": "$output.fetchVendor.data.invoiceCount === 0"
    },
    "outcomePortMap": {
      "approved": "approved",
      "rejected": "rejected",
      "manual-review": "review"
    },
    "storeAuditRecord": true
  }
}

Configuration Fields

FieldTypeDescription
ruleSetIdstring / exprThe rule set to evaluate. Managed in the Rules admin.
inputMapobjectMaps workflow data to the rule engine fact object. Values are expression-evaluated.
outcomePortMapobjectMaps rule outcomes to port names. Outcome not in map routes to the main port.
storeAuditRecordboolWhen true, stores a rule evaluation audit record with facts, outcome, and fired rules. Default: true.

RuleEvalExecutor

protected override async Task<NodeExecutionResult> ExecuteAsync(
    RuleEvalConfig config,
    NodeDataContext ctx,
    CancellationToken ct)
{
    var facts = _evaluator.EvaluateObject(config.InputMap, ctx);
    var ruleSetId = _evaluator.Evaluate<string>(config.RuleSetId, ctx);

    var result = await _ruleEngine.EvaluateAsync(new RuleEvaluationRequest
    {
        RuleSetId = ruleSetId,
        Facts = facts,
        TenantId = ctx.TenantId
    }, ct);

    if (config.StoreAuditRecord)
        await _auditLogger.LogRuleEvaluationAsync(result, ctx, ct);

    // Determine output port from outcome map
    var portKey = config.OutcomePortMap?.TryGetValue(result.Outcome, out var port) == true
        ? port
        : "main";

    return NodeExecutionResult.Success(new
    {
        result.Outcome,
        result.FiredRules,
        result.Explanation,
        result.Score,
        result.EvaluatedAt
    }, portKey: portKey);
}