Common Expression Language (CEL)

Guide to using CEL for data evaluation and transformation in workflows

CEL (Common Expression Language) is a simple expression language for evaluating conditions and manipulating data in workflows. Used in Condition Nodes, input/output expressions, and data transformation between nodes.


Workflow Data Structure

Data available in CEL expressions:

{
  prompt: "initial user input",
  input: {
    // Data from previous node
    propertyName: "value"
  },
  output: {
    // Current node execution result
    result: "data"
  }
}

Data Access:

  • input - Output from previous node
  • input.propertyName - Specific property from input
  • output - Current node result
  • prompt - Initial input from Start node

Common Operators

Comparison Operators

input.score > 80          // Greater than
input.score >= 70         // Greater than or equal
input.score < 50          // Less than
input.score <= 40         // Less than or equal
input.status == "done"    // Equal
input.status != "pending" // Not equal

Logical Operators

input.score > 80 && input.grade == "A"  // AND
input.status == "error" || input.status == "failed"  // OR
!(input.completed)  // NOT

Arithmetic Operators

input.price + 100         // Addition
input.price - 50          // Subtraction
input.quantity * 2        // Multiplication
input.total / 3           // Division
input.number % 2 == 0     // Modulo (check even)

String Operations

"Hello " + input.name     // Concatenation
input.text.size()         // String length
input.email.contains("@") // Contains check
input.text.startsWith("Hello")  // Starts with
input.text.endsWith(".com")     // Ends with

Type Conversion

string(input.count)       // Convert to string
int(input.value)          // Convert to integer
double(input.price)       // Convert to float

List Operations

input.items.size()        // List length
input.items[0]            // Access by index
5 in input.numbers        // Check if value in list

Usage Examples

1. Condition Node

// If condition
input.amount > 1000

// Complex condition
input.score >= 80 && input.attendance > 75

// String check
input.category == "urgent" || input.priority == "high"

// List check
"admin" in input.roles

2. Input Source Expression

// Get property directly
input.query

// Concat string
"Search for: " + input.topic

// Conditional value
input.useDefault ? "default query" : input.customQuery

3. Output Expression

// Format output
"Result: " + string(output.count) + " items found"

// Concat multiple properties
output.result_node + " - Sources: " + string(output.sources.size())

// Extract specific data
output.data.summary

4. Response Message

// Simple message
"Task completed successfully"

// Dynamic message
"Found " + string(input.results.size()) + " matches"

// Conditional message
input.success ? "Operation successful!" : "Operation failed"

5. API Call Body

// Access input for API payload
{
  "query": input.searchTerm,
  "limit": 10,
  "userId": input.userId
}