Overview
The if node evaluates a condition against message data and routes
messages to one of two outputs: a true branch or a false branch.
It inspects a specified field using a comparison operator and value, making it the primary building block
for decision logic in any EdgeFlow pipeline.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| field | string | "payload" | Dot-notation path to the field to evaluate (e.g. "payload.temperature") |
| operator | string | "eq" | Comparison operator: eq, ne, gt, lt, gte, lte, contains, exists |
| value | any | — | Value to compare the field against (ignored for "exists") |
| condition | string | — | Optional raw expression string evaluated as a JavaScript expression |
| _condition_result | boolean | — | Appended to msg.payload with the evaluation result (true/false) |
| _branch | string | — | Appended to msg.payload — "true" or "false" indicating selected branch |
Operators
eq / ne
Equal / Not Equal — strict comparison
field: "payload.status"
operator: "eq"
value: "active"
// true when status === "active" gt / lt / gte / lte
Numeric comparisons — greater/less than
field: "payload.temperature"
operator: "gt"
value: 30
// true when temperature > 30 contains
Substring match on string fields
field: "payload.message"
operator: "contains"
value: "error"
// true when message includes "error" exists
Check if a field is present and not undefined
field: "payload.gps"
operator: "exists"
// true when msg.payload.gps is defined
// value property is ignored Example: Temperature Threshold Routing
Route sensor data based on a temperature threshold — readings above 30 °C trigger an alert, all others are logged normally.
// If node configuration
{
"field": "payload.temperature",
"operator": "gt",
"value": 30
}
// Incoming message
{
"topic": "sensors/greenhouse",
"payload": {
"temperature": 34.5,
"humidity": 72
}
}
// Result: _condition_result = true, _branch = "true"
// Message routed to output 1 → Alert node
// If temperature were 28.0 → output 2 → Log node Example: String Matching for Error Handling
Detect error messages in log streams and route them to a dedicated error handler.
// If node configuration
{
"field": "payload.message",
"operator": "contains",
"value": "error"
}
// Incoming log message
{
"topic": "app/logs",
"payload": {
"level": "warn",
"message": "Connection error: ETIMEDOUT on port 5432",
"timestamp": "2025-06-15T08:30:00Z"
}
}
// Result: _condition_result = true, _branch = "true"
// Routed to error handler → sends Slack notification
// Messages without "error" pass to standard log storage Example: Optional Field Existence Check
Only process GPS-enabled messages that include location data.
// If node configuration
{
"field": "payload.gps",
"operator": "exists"
}
// Message WITH GPS
{
"payload": {
"device": "tracker-01",
"gps": { "lat": 51.5074, "lon": -0.1278 }
}
}
// → true branch → store in location database
// Message WITHOUT GPS
{
"payload": {
"device": "sensor-04",
"temperature": 22.1
}
}
// → false branch → skip geolocation processing Common Use Cases
Threshold Alerts
Trigger alarms when sensor values exceed safe limits
Error Routing
Separate error messages from normal log streams
Feature Flags
Enable or disable downstream paths based on config values
Data Validation
Check for required fields before processing messages