Run CEL Code
Controlled node
Overview
Evaluates an expression written in Common Expression Language (CEL) against the provided input data. CEL is a lightweight expression language designed for policy and constraint validation, supporting arithmetic, string manipulation, list operations, and boolean logic. This node is useful for performing complex conditional checks, data transformations, or calculations that would be cumbersome with simple comparison nodes.
The node uses the @marcbachmann/cel-js library to parse and evaluate expressions. If the expression evaluates successfully, the result is output as data. If evaluation fails (e.g., due to syntax errors or type mismatches), an error object is returned instead.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Run | Event | Triggers the evaluation of the CEL expression. | - |
| Code | Text | The CEL expression to evaluate. Supports arithmetic (a + b), comparisons (x > 5), string methods (name.startsWith("A")), list operations (items.exists(i, i > 0)), and map access (data.key or data["key"]). | - |
| Data | Any | The input data object or value against which the expression is evaluated. Properties of this data can be referenced directly by name in the CEL expression. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Result | Any | Contains the result of the CEL evaluation. This can be a boolean, number, string, list, or map depending on the expression. If evaluation fails, this contains an error object with a message property. |
| Done | Event | Fires when the node has finished evaluating the expression, regardless of success or failure. |
Runtime Behavior
When the Run event fires, the node evaluates the Code expression against the Data input using the CEL engine.
- Successful Evaluation: The computed value is sent to the Result output, and the Done event fires.
- Failed Evaluation: If the CEL expression contains syntax errors, references undefined variables, or encounters type mismatches (e.g., adding a string to a number), the Result output will contain an object of the form
{ error: "error message" }, and the Done event will still fire.
The node is stateless and does not cache results between runs. Each trigger re-evaluates the expression with the current inputs.
Example
Scenario: Check if a user's age is greater than 18 and their account is active.
Inputs:
- Code:
age > 18 && accountActive == true - Data:
{
"age": 25,
"accountActive": true
}
Output:
- Result:
true(boolean) - Done: Event fires
Error Example:
- Code:
undefinedVariable + 5 - Data:
{ "value": 10 } - Result:
{ error: "undefinedVariable is not defined" }