New to Kestra?
Use blueprints to kickstart your first workflows.
React to MQTT alarms in real time with Kestra. A realtime trigger starts one execution per message and posts topic and severity to Discord.
Polling is the wrong shape for alarms. This blueprint uses io.kestra.plugin.mqtt.RealtimeTrigger to hold a live subscription on alarms/# and start one execution per message the instant it arrives, no interval, no batch, no polling gap. Each execution carries the message as trigger.* values: the flow logs the alarm for the audit trail and posts the source topic and severity to Discord, turning a device-side fault into an on-call notification in sub-second time.
alarm_stream (io.kestra.plugin.mqtt.RealtimeTrigger) connects to the broker from the MQTT_SERVER secret and subscribes to the alarms/# wildcard. Unlike the plugin's polling trigger, the realtime trigger keeps the subscription open and fires per message, so reaction time is bounded by the broker, not by an interval.{{ trigger.topic }} names the exact subtopic that raised the alarm, and because serdeType: JSON parses the payload, individual fields such as {{ trigger.payload.severity }} are addressable as scalars. The trigger also exposes id, qos, and retain per message.log_alarm writes the topic and payload fields into the execution logs, giving every alarm a searchable record.alert_discord posts the topic, severity, device id, and detail to Discord as plain scalars.errors block posts a distinct Discord alert when handling fails, so a broken reactor is itself alarmed.disabled: true; enable it once the broker secret is in place.alarms/.A bridge script that subscribes and forwards to a webhook works until it crashes at 3 a.m. with nobody watching. Kestra runs the subscription as a supervised trigger, records every alarm as an execution with logs and timings, retries the notification on transient failures, and alerts when handling breaks. Adding a second reaction, such as opening a ticket or publishing a command back to the device, is one more task in the same flow.
alarms/#, e.g. payloads like {"severity": "critical", "device_id": "dev-001", "detail": "overheat"}. Public test brokers accept anonymous connections; for authenticated brokers, add the username and password properties to the trigger from secrets.MQTT_SERVER: broker URI, e.g. tcp://broker.example.com:1883.DISCORD_WEBHOOK_URL: Discord incoming webhook URL.MQTT_SERVER and DISCORD_WEBHOOK_URL secrets to your Kestra namespace.disabled: false on the alarm_stream trigger and save the flow.mosquitto_pub -t alarms/dev-001 -m '{"severity": "critical", "device_id": "dev-001", "detail": "overheat"}'.io.kestra.plugin.core.flow.If, paging only on critical and logging the rest.