New to Kestra?
Use blueprints to kickstart your first workflows.
Dispatch JSON commands to per-device MQTT topics from a Kestra flow with QoS 1 delivery, Slack confirmation, and an audit trail for every command.
Stop sending fleet commands with ad hoc mosquitto_pub calls from someone's laptop. This blueprint turns a device command into a first-class Kestra execution: the io.kestra.plugin.mqtt.Publish task builds a JSON command document from typed flow inputs, publishes it to devices/<device_id>/commands with QoS 1, and posts a Slack confirmation. Every dispatch carries the operator's inputs, a reason, and the execution id, so the question "who restarted that device and why" has an answer in the execution history instead of a shell history.
device_id selects the target topic, command is constrained to a fixed verb list by a SELECT input, and reason records the justification.publish_command (io.kestra.plugin.mqtt.Publish) connects to the broker from the MQTT_SERVER secret and publishes the command as a JSON map (serdeType: JSON) to devices/{{ inputs.device_id }}/commands. qos: 1 makes the broker acknowledge delivery at least once, and the payload embeds execution_id and issued_at so the device can correlate and deduplicate.messagesCount, the number of messages published, which flows into the confirmation.notify posts the command, target topic, publish count, and reason to Slack.errors block posts a distinct Slack alert when the publish fails, naming the command and device that did not receive it.SELECT input, so typos never reach devices.command, reason, issued_by, execution_id, issued_at) devices can validate.Publishing one MQTT message is easy; making it accountable is not. Kestra wraps the publish with typed inputs, secret management for the broker URI, retries on transient broker failures, a Slack paper trail, and an execution history that doubles as the command log. The same flow becomes an API endpoint, a scheduled job, or a subflow inside a larger maintenance pipeline without changing the publish task.
username and password properties to the task from secrets.devices/+/commands.MQTT_SERVER: broker URI, e.g. tcp://broker.example.com:1883.SLACK_WEBHOOK_URL: Slack incoming webhook URL.MQTT_SERVER and SLACK_WEBHOOK_URL secrets to your Kestra namespace.devices/dev-001/commands, e.g. mosquitto_sub -t 'devices/+/commands'.command value list to match your device firmware's verbs.io.kestra.plugin.core.trigger.Webhook so an internal tool can dispatch commands over HTTP.io.kestra.plugin.core.flow.ForEach around the publish task.qos to 2 for exactly-once semantics where the broker and devices support it.