Reference · Tools

MQTT

Publish messages to MQTT broker topics.

Action Communication v1

The MQTT node publishes messages to broker topics with configurable quality of service and retain flag. A typical build is pushing a command onto a device topic when a workflow decides something should change — turning equipment on, or broadcasting a new setpoint.

Node type
Action
Parameters
5
Outputs
Output, Error
Credentials
MQTT

MQTT

Publish messages to MQTT topics.

Overview

MQTT publishes messages to topics on an MQTT broker. For each input item, it publishes either the full item JSON (when sendInputData is true) or a custom message string to the specified topic. Supports QoS levels 0 (at most once), 1 (at least once), and 2 (exactly once), as well as the MQTT retain flag. Connects per execution using the mqtt npm package. Supports MQTT, MQTTS (TLS), and WebSocket transports. Input items are passed through unchanged after publishing.

Category: Communication
Tool Name: mqtt
Version: 1

Appearance: Icon: lucide-Radio | Color: #660066

Node Type

Action — processes input items and produces output

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires MQTT credentials. See the Credentials Guide for setup instructions.

Parameters

ParameterTypeRequiredDefaultDescription
TopicstringYesThe MQTT topic to publish the message to. Supports expressions like {{ $json.deviceId }}.
Send Input DatabooleanNotrueWhether to send the input item data as JSON for the message body. When enabled, the entire input item JSON is serialized and published.
MessagestringYesThe custom message string to publish. Only used when “Send Input Data” is disabled. Supports expressions. (shown when Send Input Data is false)
OptionscollectionNo{}Additional publish options.
— QoSoptionsNo0Quality of Service level. 0 = at most once (fire and forget), 1 = at least once (acknowledged delivery), 2 = exactly once (assured delivery).
Options: 0 (Received at Most Once), 1 (Received at Least Once), 2 (Exactly Once)
— RetainbooleanNofalseWhether to set the MQTT retain flag. When set, the broker keeps the last retained message on this topic for new subscribers.
Max ConcurrencynumberNo10Maximum number of items to process concurrently.

Output Data

This node does not fan out and does not add any fields. Each input item is published to the broker and then passed straight through to Output — the item JSON is unchanged and binary data is forwarded, so downstream nodes see exactly what arrived.

Because nothing is added, use the presence of an item on Output as the signal that its publish succeeded; a publish that failed becomes an item error instead.

Usage Examples

  • Publish sensor data to an MQTT topic
  • Send a custom alert message to an MQTT broker
  • Push IoT device commands via MQTT with QoS 2 guaranteed delivery
  • Broadcast JSON payloads to MQTT subscribers

Example Configuration

Basic usage — publish the whole input item as JSON:

{
  "type": "mqtt",
  "parameters": {
    "topic": "sensors/temperature",
    "sendInputData": true
  }
}

Custom message with acknowledged delivery and retention:

{
  "type": "mqtt",
  "parameters": {
    "topic": "alerts/critical",
    "sendInputData": false,
    "message": "System alert: High temperature detected",
    "options": {
      "qos": 1,
      "retain": true
    }
  }
}

High-reliability configuration — exactly-once delivery:

{
  "type": "mqtt",
  "parameters": {
    "topic": "devices/status/device123",
    "sendInputData": true,
    "maxConcurrency": 5,
    "options": {
      "qos": 2,
      "retain": false
    }
  }
}

Fire-and-forget notification:

{
  "type": "mqtt",
  "parameters": {
    "topic": "notifications/info",
    "sendInputData": false,
    "message": "Process completed successfully",
    "options": {
      "qos": 0,
      "retain": false
    }
  }
}

Sensor data publishing — build the topic per item so one node serves every device:

{
  "type": "mqtt",
  "parameters": {
    "topic": "sensors/{{ $json.deviceId }}",
    "sendInputData": true,
    "options": {
      "qos": 1
    }
  }
}

Alert messages — a custom body instead of the item JSON:

{
  "type": "mqtt",
  "parameters": {
    "topic": "alerts/{{ $json.severity }}",
    "sendInputData": false,
    "message": "Alert: {{ $json.description }}",
    "options": {
      "qos": 1,
      "retain": true
    }
  }
}

Status updates that new subscribers should see immediately:

{
  "type": "mqtt",
  "parameters": {
    "topic": "devices/status",
    "sendInputData": true,
    "options": {
      "qos": 1,
      "retain": true
    }
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Publish messages to MQTT broker topics with configurable QoS and retain flag; use when you need to send data to IoT devices or message brokers over MQTT.

Frequently asked questions

What does the retain flag do?

It tells the broker to keep the message as the last known value on that topic, so a client subscribing later receives it immediately rather than waiting for the next publish.

Which QoS level should I use?

It depends on the delivery guarantee you need — higher levels trade throughput for stronger assurance. Match it to what the subscribing devices expect.

Can it subscribe as well as publish?

This node publishes. It is the outbound half — sending data to devices or brokers rather than listening for it.

Which credential does it need?

An MQTT credential holding the broker connection details.

Build with the MQTT node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need MQTT credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.