Overview
Complete reference for all LoT operations available within actions. These operations allow you to manipulate variables, perform calculations, transform strings, read and write MQTT topics, and implement conditional logic.Variable Operations
SET, GET TOPIC, GET JSON, and GET PROTO are the core operations for working with data in actions. They allow you to store values, read from MQTT topics, extract fields from JSON payloads, and decode protobuf fields.
SET
Creates or assigns a value to an internal variable:{variable_name}.
- Static Value
- From Topic
- Calculated
Variable names must be enclosed in double quotes when using SET, but referenced with curly braces:
SET "myVar" WITH 10 then use {myVar}.GET TOPIC
Retrieves the last known value from a topic. If the topic has no value, the broker returns a default based on the requested type.Default Values for Missing Topics
Type Casting
Wildcard Inheritance
When an action is triggered by a wildcard topic pattern, GET TOPIC inherits the matched wildcard values:Example Usage
GET JSON
Extracts fields from JSON payloads with support for nested paths and arrays.For narrative patterns, missing-field workflows, and end-to-end
PUBLISH MODEL examples, see Working with JSON.Basic Syntax
Supported Types
Nested Path Extraction
Use dot notation to access nested objects and bracket notation for arrays:Error Handling
If a field doesn’t exist, the result depends on the requested type:
Use EMPTY check for conditional handling:
Complete Example
GET PROTO
Extracts fields from binary protobuf MQTT payloads.GET PROTOBUF is the same verb. You need a matching DEFINE MODEL with WITH FORMAT PROTOBUF (or BOTH) and PROTO_TAG values that follow the vendor .proto. Full models, type mapping, and pitfalls: Protobuf Models.
Basic Syntax
USING MODEL names the top-level message, even on a nested dotted path. Supported AS types: INT, DOUBLE, FLOAT (alias SINGLE), STRING, BOOL, BYTES.
A missing or mismatched field returns null (not a type default). That usually means a wire-type mismatch, for example ADD DOUBLE on a proto float.
Declare the parent message (unused arms stay as ADD OBJECT so wire numbers do not shift):
ADD MODEL, and keep USING MODEL on the top-level message:
GET MODEL
GET MODEL reads one record from a database connector and returns it shaped as a model: a JSON object with that model’s fields.
Basic Syntax
- The query reads the table, collection, or index with the same name as the model, not the
STORE INtable. WHERE(orWHEN) filters on columns. Operators areEQUALS,==,!=,>,<,>=, and<=. Join conditions withANDin any mix of text and numeric comparisons. Text values are single-quoted, and a literal'is written''(the nameO'Brienis'O''Brien'). A{var}value is resolved when the action runs.ORis not supported and is a syntax error.- The first matching record is returned. A model field the record doesn’t have gets its type’s default (
0,0.0,false, or""). - With no match, an unknown model, or a query error, the result is an empty object
{}, and the error goes to the broker log.
FILE_STORAGE, and REST_API.
Example Usage
Read the press row when its id, state, and temperature all match.{machine} is filled in when the action runs.
GET MODEL runs inside the action and waits for the database. Keep it off high-rate triggers. In a cluster, a connector that runs only on its owner node, such as FILE_STORAGE, answers there only: on another node the call fails and names the owner.
Environment Variables & Secrets
Version Requirement:
GET ENV, GET SECRET, KEEP ENV, KEEP SECRET, DELETE ENV, and DELETE SECRET are available from Coreflux Broker v1.9.3 and above.GET ENV
Reads an environment variable. The broker checks the managed.env file first, then falls back to process, user, and machine environment variables. Returns an empty string if not found.
Examples
KEEP ENV
Persists a new environment variable to the.env file on disk:
DELETE ENV
Removes an environment variable from the managed.env file:
GET SECRET
Reads an encrypted secret fromsecrets.json, decrypting it at runtime. Returns an empty string if the secret does not exist.
Examples
KEEP SECRET
Encrypts and persists a new secret tosecrets.json:
DELETE SECRET
Removes a secret fromsecrets.json:
Complete Example
For full details on environment variable resolution order, encryption key management, and deployment configuration, see Environment Variables & Secrets.
Arithmetic Operators
LoT supports standard arithmetic operations that work with numeric types (INT, DOUBLE) and can be combined with GET TOPIC, PAYLOAD, and variables.Supported Operators
Syntax
Basic Examples
Using with Variables
Using with GET TOPIC
Using with PAYLOAD
Operator Precedence
Operations follow standard mathematical precedence:- Parentheses
()- highest priority - Unary negation
- - Multiplication
*, Division/, Modulo% - Addition
+, Subtraction-
Complete Example
String Concatenation
The+ operator concatenates strings, allowing dynamic construction of topics, messages, and values.
Syntax
Basic Examples
Dynamic Topic Construction
Combining Strings with Other Types
Complete Example
RANDOM Function
Generates random values of various types including numeric ranges and unique identifiers.Syntax
Random Integers
Random Doubles
Unique Identifiers
Use Cases
- Simulation
- Unique IDs
- Load Balancing
Generate test data for sensors:
String Transformations
LoT provides string transformation operations for filtering, replacing, and parsing text data.FILTER
Extracts content from a string using a regular expression pattern.Syntax
Supported Sources
PAYLOAD- The incoming message payloadGET TOPIC "path"- Value from an MQTT topic{variable}- A previously set variable"string literal"- A hardcoded string
Examples
Common Regex Patterns
REPLACE
Replaces occurrences of a pattern with a new value.Syntax
Examples
Multiple Replacements
SPLIT CSV
Parses CSV (Comma-Separated Values) data from the payload into a structured format.Syntax
Parameters
Example
SPLIT CSV currently only supports PAYLOAD as input. Support for GET TOPIC and variables is planned for future releases.
Topic Operations
PUBLISH vs KEEP — When to Use Which
Use
KEEP TOPIC for inter-action state (counters, mode flags, last-known values). Use PUBLISH TOPIC when connectors, UIs, or other subscribers must react to the message. Use PUBLISH TOPIC ... RETAIN when new subscribers must receive the last payload.
PUBLISH TOPIC
Sends a message to an MQTT topic. Current subscribers receive it immediately; the message can trigger other actions or connectors listening on that topic. OptionalRETAIN sets the MQTT retain flag on the published message (the same keyword as on DEFINE MODEL). Optional QOS0, QOS1, or QOS2 select MQTT QoS; the default remains QoS 0. Omitting RETAIN keeps the historical non-retained behaviour. RETAIN and a QoS keyword can appear in either order (RETAIN QOS1 or QOS1 RETAIN).
KEEP TOPIC is different: it stores a value for GET TOPIC in the broker cache and does not set the MQTT retain flag. Use PUBLISH TOPIC ... RETAIN when new subscribers must receive the last payload. KEEP does not accept RETAIN.
Several PUBLISH TOPIC or KEEP TOPIC lines to the same topic in one run each go out, in the order the action wrote them, with that line’s own retain, QoS, and keep setting. A later GET TOPIC in the same run still reads the value just written. In a cluster, only the last KEEP of each topic is replicated.
Syntax
- Retain
- Retain and QoS 1
- QoS only
Store the last status so a new subscriber receives the last payload:
Value Types
You can publish various value types:Binary passthrough — PAYLOAD AS BYTES
Use AS BYTES when the incoming MQTT payload must be forwarded, or stored with KEEP TOPIC, bit-for-bit — for example protobuf messages, Modbus frames, or image chunks. Untyped WITH PAYLOAD still uses the string publish path and may corrupt non-UTF-8 data. To decode or encode protobuf fields rather than forward the blob, use Protobuf Models (GET PROTO / PUBLISH MODEL). To hand those bytes to an external gRPC service, publish them on the source topic of a gRPC connector (TYPE GRPC). There is no CALL GRPC.
KEEP TOPIC and SET accept the same binary form, so you can store raw frames for later reads with GET TOPIC:
Dynamic Topics
Build topic paths dynamically using string concatenation:Multiple Publishes
Actions can publish to multiple topics:KEEP TOPIC
Stores a value forGET TOPIC in the broker cache. Unlike SET (which exists only during one execution), a KEEP value stays available to later runs on this broker. It is a broker-internal cache and never sets the MQTT retain flag. KEEP does not accept RETAIN (use PUBLISH TOPIC ... RETAIN).
When to Use KEEP
Syntax
Example: Persistent Counter
KEEP vs PUBLISH Comparison
Control Flow
IF … THEN … ELSE
Execute different logic based on conditions.Comparison Operators
Basic Conditionals
Nested Conditionals
For multiple conditions, nest IF statements:Checking for Empty Topics
UseEMPTY to check if a topic has no value:
Combining with Expressions
Timestamps
Add timestamps to your messages for tracking, logging, and debugging. LoT supports two timestamp formats.Supported Formats
Syntax
Using with PUBLISH and KEEP
Using with SET
Complete Example
Callable Actions
LoT supports callable actions - actions that can be invoked by other actions with input parameters and return values. This enables modular, reusable logic blocks.For reusable logic, on-demand scripts, and composition patterns, see Callable ACTIONs.
Defining a Callable Action
Supported Input Types
STRINGINTDOUBLEBOOLJSON
Calling an Action
Basic Example
- Define
- Call
Create a reusable calculation:
Multiple Outputs
Utility Action Library
Build reusable utility actions for common operations:TRIGGER Statement
The TRIGGER statement allows actions to programmatically trigger connector events or mappings. This is useful for initiating data pipeline operations or triggering external integrations.Syntax
Components
Basic Examples
Complete Example
Use Cases
- Email Notifications
- Database Operations
- External APIs
CALL MCP
CALL MCP allows actions to invoke tools provided by MCP (Model Context Protocol) connectors. This enables integration with AI assistants and external tools.CALL MCP talks to an MCP connector (TYPE MCP) — the broker as a client of an external server. To let an AI client operate this broker, enable the MCP Server instead. TYPE MCP_SERVER was removed.A gRPC connector (TYPE GRPC) is also a client connector, and it is not invoked with CALL. It forwards MQTT payloads from SOURCE_TOPIC.Prerequisites
- An MCP connector must be defined and active
- The connector must expose the tool you want to call
Syntax
Example MCP Connector
Basic Examples
Return Value
RETURN AS receives a JSON string with success, tool_name, route_name, timestamp, and execution_time_ms. A successful call adds result, the server’s tool result. A failed call adds error instead. See Return Value.
Complete Example
CALL LLM
CALL LLM sends a prompt to a TYPE LLM connector and returns JSON. The connector does not call tools. For an assistant that can read topics or publish, use CALL AGENT.
generate is one turn. chat with use_history = "true" keeps an in-memory thread per session_id. clear_history drops that thread. INVOKE LLM is the same call. Check success in the JSON before you use response.
CALL AGENT
CALL AGENT runs a DEFINE AGENT and waits for the answer. The call runs as the agent’s DEFAULT_USER. execute returns the answer text, or JSON { "success": false, "status", "code", "message" } when the task is refused or fails.
clear_history takes session_id and forgets that session for DEFAULT_USER. A name that is not a running agent returns unknown_agent.
Complete Example
This example combines the key operations covered on this page—SET, GET TOPIC, GET JSON, arithmetic, IF/THEN, PUBLISH, and KEEP—in a realistic sensor processing action.What This Action Does
- Triggers on any message to
sensors/+/datatopics - Extracts the sensor ID from the topic path
- Parses the JSON payload to get temperature value
- Converts Celsius to Fahrenheit using arithmetic
- Alerts if temperature exceeds threshold
- Publishes formatted data to processed topics
- Caches the raw payload for future reference
Quick Reference
Next Steps
Python Integration
Extend actions with Python functions for complex logic.
LoT Notebooks
Run and deploy these operations from VS Code with LoT Notebooks.

