Basic Edge
The simplest form of edge is one that connectsnodeA to nodeB, where the output of nodeA is passed as input to nodeB without any conditions.
Conditional Edge
You can create an edge with a condition that determines whether data flows through the edge. There are two ways you can define conditions:- Common Expression Language expressions: Define the logic using CEL expressions.
- Custom condition: Define a function that returns either true or false.
Common Expression Language (CEL)
Common Expression Language (CEL) implements common semantics for expression evaluation that can be used to define edge conditions. CEL expressions operate on the output of the source node, which is accessible via theinput variable.
Some examples of supported operators include:
input.content == 'foo'- Returns true if input content is equal to the constant string literal argument.input.intent_name == "greeting"- Returns true if the intent name equals “greeting”.size(input) > 0- Returns true if the size of input is greater than 0.int(input.content) > 50- Returns true if the numeric value of input content is greater than 50.
nodeA to nodeB if the numeric value of the content is greater than 50.
Basic Syntax
CEL expressions are used in theconditionExpression parameter when adding edges to your graph:
Understanding the Input Object
In CEL expressions,input refers to the data output from the source node that the edge is connected to. When an edge is evaluated, CEL receives the previous node’s output as the input object.
Example flow
Key Points
input= output data from the source node of the edge- Structure varies based on what the source node produces
- Always verify the source node’s output format before writing CEL expressions
The Data Store Object
In addition toinput, CEL expressions also have access to a data_store object that provides persistent storage across graph execution. The data store allows you to share state between different nodes and maintain context throughout the graph’s lifecycle.
Data Store Operations
Checking if a Variable Exists
Getting a Variable Value
text property, so you need to access .text to get the actual value:
Data Store vs Input
| Aspect | input | data_store |
|---|---|---|
| Scope | Current edge only | Entire graph execution |
| Source | Previous node’s output | Persistent storage across nodes |
| Lifecycle | Per edge evaluation | Graph lifetime |
| Use Case | Node-to-node data flow | Cross-node state management |
Data Type Limitations
Important: The Inworld Agent Runtime only supports simple data types in node inputs and outputs. Complex JavaScript objects and class instances are not supported.Supported Types:
- Primitives:
string,number,boolean - Arrays of primitives:
string[],number[],boolean[] - Plain objects with primitive properties:
{ name: string, age: number } - Nested plain objects:
{ user: { id: string, tier: string } }
Conditional expressions in code
For more advanced conditions that cannot be expressed by CEL expressions, a condition function can be defined directly in the edge configuration. In the example below, data only flows fromnodeA to nodeB if the custom condition function returns true.
Optional Edge
Marks an edge as optional, meaning the destination node can execute even if it doesn’t receive input through this edge. Optional edges are useful when a node can function with or without certain inputs.Loop Edge
Creates a loop in the graph, allowing for iterative processing. The below example creates a self-loop where the output ofnodeA is fed back as its input, enabling iterative processing until a condition is met.