Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cognigy.com/llms.txt

Use this file to discover all available pages before exploring further.

Updated in 2026.5

Syntax

evaluateRule(rule)

Description

Evaluates a condition based on a rule configuration that follows the left, operator, right pattern. This function works similarly to the If Node. The left value is compared with the right value using the specified operator (for example, !=, >, includes). If the condition evaluates to true, the associated logic or transition is executed. This function is asynchronous. Parameters:
  • rule: IRule – a rule configuration object.
export const ruleOperands = <const>[
    "lt",
    "lte",
    "eq",
    "neq",
    "gt",
    "gte",
    "exists",
    "nexists",
    "contains",
    "ncontains",
    "isyes",
    "isno"
];

export type TRuleOperand = typeof ruleOperands[number];

export interface IRule {
    left: string;
    operand: TRuleOperand;
    right: string;
}
Returns: Promise<boolean> – a promise that resolves to true if the rule condition is met, otherwise false.

Example

const rule: IRule = {
  left: "hello world",
  operand: "contains",
  right: "hello"
};

const result = await evaluateRule(rule);

console.log(result); // true