Skip to main content

Logic Nodes

Logic nodes evaluate conditions and route the automation flow to different branches. Each branch corresponds to an output handle on the node.

Create a project​

lumio init my-logic-node

When prompted:

  • Category: automation_node
  • Node type: Logic

Handler​

Logic handlers use defineAutomationLogic and return a branch key:

import { defineAutomationLogic } from "@zaflun/lumio-sdk/server";

defineAutomationLogic(async (ctx) => {
const value = ctx.inputData.amount;
if (value > ctx.nodeConfig.threshold) {
return "above";
}
return "below";
});

Return value​

The handler returns a string -- the branch key. This string must match one of the output handle keys defined in the Automation Builder.

Common patterns:

PatternBranch keysUse case
Boolean"true", "false"Simple yes/no condition
Threshold"above", "below"Numeric comparison
Match"match", "no_match"Pattern matching
Category"category_a", "category_b", "other"Multi-way routing

The Automation Builder displays output handles for each unique branch key that the node can return. Users connect edges from these handles to downstream nodes.

Input data​

Logic nodes receive data from the upstream node via ctx.inputData. The input_schema in the manifest defines expected fields:

{
"node_type": "logic",
"node": {
"input_schema": {
"type": "object",
"properties": {
"amount": { "type": "number", "title": "Amount to check" }
},
"required": ["amount"]
},
"output_schema": {
"type": "object",
"properties": {}
}
}
}

Logic nodes typically have an empty output_schema since they route rather than transform data. The upstream data passes through unchanged to the selected branch.

Example: Time-of-day router​

import { defineAutomationLogic } from "@zaflun/lumio-sdk/server";

defineAutomationLogic(async (ctx) => {
const hour = new Date().getUTCHours();
const offset = Number(ctx.nodeConfig.utc_offset ?? 0);
const localHour = (hour + offset + 24) % 24;

if (localHour >= 6 && localHour < 12) return "morning";
if (localHour >= 12 && localHour < 18) return "afternoon";
if (localHour >= 18 && localHour < 22) return "evening";
return "night";
});

Timeout​

Logic nodes have a 2000ms timeout. Keep logic simple. Automation nodes cannot fetch external data; use data already present in the node's input or configuration.

Next steps​