Skip to main content

When to Use Action Models

Action models (COLLAPSED models) are templates for structured data that you publish explicitly from within actions. They’re ideal when you need:
  • Control over timing - Publish only when specific conditions are met
  • Dynamic routing - Send data to different topics based on logic
  • Data transformation - Process and enrich data before structuring
Unlike basic models that trigger automatically on topic changes, action models let you decide exactly when and where structured data is created. With WITH FORMAT PROTOBUF, that output is binary protobuf bytes rather than JSON — see Protobuf Models.

Example Use Case

Imagine you receive raw alarm data and need to:
  1. Extract relevant fields from JSON
  2. Add a unique ID and timestamp
  3. Route critical alarms to a special topic
  4. Publish a structured record

Step-by-Step Guide

1

Define a COLLAPSED Model

Create a template with all required fields. The COLLAPSED keyword indicates this model has no automatic trigger:
2

Create the Processing Action

Define an action that extracts data and publishes the model:
3

Test the Flow

Publish to: sensors/temp001/json_data
Result at: sensors/processed/temp001

Use Case Examples

Route alarms by severity while creating structured records:

JSON vs protobuf on the destination topic

PUBLISH MODEL writes whatever format the model declares: Trigger-based models (WITH TOPIC + AS TRIGGER) still auto-publish JSON. Use a COLLAPSED model and PUBLISH MODEL when a gateway must receive protobuf. Nested messages you fill on publish use ADD MODEL Child "field", not indented ADD OBJECT.
The Action copies JSON tags into that envelope and publishes bytes:
Full type mapping, PROTO_TAG, and GET PROTO are on Protobuf Models.

Best Practices

Explicit type casting prevents runtime errors:
Check data before publishing:
Include identifiers in output topics for easy filtering:
Use RANDOM UUID for record identification:

Next Steps

Model Examples

See complete examples for common use cases.

Action Operations

Review available operations for action logic.
Last modified on September 4, 2026