Icon for n8nIcon for Mosquitto

n8n + Mosquitto: MQTT-triggered workflow automation

Integrates withCurated

n8n connects to Mosquitto via its native MQTT Trigger node. When a device publishes a message to a Mosquitto topic (e.g., factory/line-3/temp), n8n receives the message and begins executing a workflow — no polling required. This makes Mosquitto the edge data source and n8n the downstream business logic engine.

How it works

IoT Device → Mosquitto broker (port 1883)
                    ↓
         n8n MQTT Trigger node (subscriber)
                    ↓
         n8n workflow (transform, route, store, notify)
                    ↓
         ERP / Database / Slack / Email / AI

n8n acts as an MQTT client subscribing to one or more topics. Mosquitto handles QoS, session persistence, and retained messages — n8n processes each message as a workflow execution.

Use cases

  • Threshold alerting — temperature/pressure reading arrives on MQTT → n8n checks against threshold → creates ticket in Jira or sends Slack alert
  • Data routing — machine state change on MQTT → n8n normalizes payload → writes to PostgreSQL or InfluxDB
  • Production tracking — unit completion event on MQTT → n8n updates ERP production order count
  • Shift reporting — n8n aggregates all MQTT events over a shift → generates PDF summary → emails to supervisor

Configuration

  1. In Mosquitto: ensure port 1883 (or 8883 for TLS) is accessible from the n8n host
  2. In n8n: add MQTT Trigger node → set broker host/port → enter topic pattern (wildcards supported: + single level, # multi-level)
  3. Configure credentials (username/password or client certificate for TLS)
  4. Set QoS level (0 for fire-and-forget, 1 for at-least-once, 2 for exactly-once)
  5. Connect downstream nodes to process the body output (JSON-parsed message payload)

Tradeoffs

  • n8n is not a real-time stream processor — each MQTT message spawns a workflow execution; high-frequency topics (>10 msg/sec) will consume execution quota rapidly
  • Mosquitto has no rule engine; n8n provides the logic layer, but this adds a network hop vs. in-broker processing (as EMQX offers)
  • For very high-throughput MQTT streams, consider buffering via a time-series DB and polling n8n on a schedule instead of per-message triggers