MQTT

App · 2 actions

Publish messages to any MQTT broker, such as Mosquitto, HiveMQ, EMQX or AWS IoT Core, read a topic's latest message, and start a workflow when a sensor, machine or app sends a message to a topic.

Get the latest message

Read the message the broker keeps as a topic's latest, such as a device's last reported state. Only messages published with Keep as the topic's latest message (retained) are kept; found is false when there is none.

Inputs

TopictopictextRequired
The topic, such as factory/line-1/status. Topics are paths separated by /, and capitals matter. It can't contain + or #.

Outputs

The topic's kept message, if the broker keeps one.

foundtrue/false
Whether the broker keeps a message for the topic. When false, message is empty.
is_binarytrue/false
Whether the message isn't text, so message holds it as base64.
is_jsontrue/false
Whether the message was JSON and has been read into fields.
messageobject
The message: its JSON read into fields when it is JSON, its text otherwise, or base64 when it isn't text (is_binary is then true).
size_bytesnumber
The message's size in bytes.
topictext
The topic read.
Example output
{
  "found": true,
  "is_binary": false,
  "is_json": true,
  "message": {
    "state": "running",
    "temperature": 41.5
  },
  "size_bytes": 42,
  "topic": "factory/line-1/status"
}

Publish a message

Send a message to a topic on the broker, for the devices and apps subscribed to it: a command to a machine, a reading, an alert. An object or list from an earlier step is sent as JSON.

Inputs

TopictopictextRequired
The topic, such as factory/line-1/status. Topics are paths separated by /, and capitals matter. It can't contain + or #.
Messagemessagetext
What to send: text, or an object or list from an earlier step, which is sent as JSON. Leave it empty to send an empty message; with Keep as the topic's latest message on, that clears the message the broker keeps.
Deliverydeliverytext
At least once waits for the broker to confirm it has the message, so the step fails if it doesn't arrive. At most once sends it without waiting, for frequent readings where one lost message doesn't matter.One of: at_least_once (At least once: the broker confirms it got the message), at_most_once (At most once: send it without waiting for the broker). Default: at_least_once.
Keep as the topic's latest messagekeep_as_latesttrue/false
The broker keeps this message and hands it to anyone who subscribes to the topic later, such as a device's current state. Get the latest message reads it back. Each kept message replaces the one before.Default: false.

Outputs

The message that was published.

confirmed_by_brokertrue/false
Whether the broker confirmed it has the message: true for At least once.
deliverytext
How it was delivered: at_least_once or at_most_once.
is_binarytrue/false
Whether the message isn't text, so message holds it as base64.
is_jsontrue/false
Whether the message was JSON and has been read into fields.
kept_as_latesttrue/false
Whether the broker keeps it as the topic's latest message.
messageobject
The message: its JSON read into fields when it is JSON, its text otherwise, or base64 when it isn't text (is_binary is then true).
size_bytesnumber
The message's size in bytes.
topictext
The topic it was published to.
Example output
{
  "confirmed_by_broker": true,
  "delivery": "at_least_once",
  "is_binary": false,
  "is_json": true,
  "kept_as_latest": false,
  "message": {
    "action": "start",
    "speed": 40
  },
  "size_bytes": 31,
  "topic": "factory/line-1/commands"
}

On this page