Resources · n8n integration

MQTT n8n integrationAutomate MQTT with n8n.

Your devices already talk to a broker, so why keep n8n out of that conversation? An MQTT n8n integration rests on two nodes: the MQTT node publishes a message to a topic you name, and the MQTT Trigger subscribes to topics and starts a workflow when a message lands there. One operation, one credential, one broker.

Verified Trustpilot reviews · AI, automation & growth agency

Why automate

What does an MQTT n8n integration actually give you?

MQTT is a publish and subscribe protocol: a device sends a message to a topic on a broker, and everything subscribed to that topic receives a copy. n8n ships two nodes for it. The MQTT node publishes, with Topic and Message as its two required fields. The MQTT Trigger goes the other way, listening on the topics you hand it so that an incoming message starts a workflow.

Start with the reading side, because that is where most MQTT work begins. A workshop full of temperature probes publishes on topics like plant/line1/temp. The MQTT Trigger subscribes, and every message becomes an item you can append to a sheet through Google Sheets or store in a table through Postgres. No script on the device side, no polling loop to maintain.

Second scenario: routing. A door sensor publishes once when it opens outside working hours, and the workflow turns that raw payload into a readable line in a channel with Slack. The Only Message option is what makes that pleasant, since it strips the envelope and leaves you the payload alone.

Third scenario: writing back. The MQTT node publishes a command to a device topic, and the Retain option tells the broker to keep that last message. Normally a message published to a topic with no subscriber is discarded. With Retain on, a device that connects later still picks up the last instruction it missed.

One thing worth saying plainly, because it changes how you plan a project. On most integrations, when an operation is missing you drop in a generic HTTP node and call the API yourself. That is not the case here. The MQTT credential opens a connection to a broker, not an HTTP API, so there is no generic node to fall back on. What these two nodes expose is what n8n can do with MQTT.

So the honest limit: the node publishes, and that is all it does. Reading happens through the trigger, and anything else your broker offers stays outside n8n. If you are weighing platforms before you build, the n8n review covers the ground, and n8n training goes through credentials and expressions properly.

Connect

How do you connect n8n to your MQTT broker?

  1. 01

    Get a broker running first

    The credential connects to a broker, so one has to exist before n8n has anything to talk to. MQTT publishes a list of servers and brokers on its own site, and your provider's documentation is the reference for the connection details. Keep three things within reach for the next step: the Protocol the broker expects, its Host, and the Port it accepts connections on.

  2. 02

    Create the broker connection credential

    In n8n, open the Credentials menu and create an MQTT credential, the reusable saved login that both nodes read from a dropdown. Pick the Protocol, which decides the URL n8n builds: Mqtt for a standard mqtt: URL, Mqtts for the secure mqtts: one, Ws for a WebSocket ws: URL. Then fill the Host, the Port, and the Username and Password the broker expects.

  3. 03

    Set the session and certificate options

    Two toggles are worth a look before saving. Turn Clean Session off if you want to receive QoS 1 and 2 messages that arrived while the connection was down. Leave Client ID blank and n8n generates one, though a fixed or expression based value helps you identify a connection later; n8n suggests putting n8n in it for easier auditing. If your broker uses SSL, turn the SSL toggle on and add the certificates it asks for.

Triggers

What starts a workflow from MQTT ?

MQTT Trigger is the node that starts a workflow when something happens in MQTT. Activate the workflow and every event it receives becomes one execution.

What you see in n8n

Configuration notes

01Subscribe to topics with the MQTT TriggerVersion 1 of the MQTT Trigger holds a subscription open on your broker and hands each incoming message to the workflow as an item.

Version 1 of the MQTT Trigger holds a subscription open on your broker and hands each incoming message to the workflow as an item.

Key parameters

  • Topics: the topics to subscribe to, several at once separated by commas. Wildcard characters work, + for a single level and # for multiple levels, so plant/+/temp catches every line and plant/# catches the whole tree.
  • Topics also carries the quality of service. Every subscription uses QoS 0 by default; write the level you want after a colon to change it, as in topicA:1,topicB:2.
When to use it
whenever the broker is the source of truth and you want n8n to react to what devices publish instead of asking them. Nothing arrives while the workflow is inactive, so activate it once the topics are right.
02Shape the payload with trigger OptionsThe Options collection decides what the rest of your workflow actually receives, and getting it right here saves a Code node later.

The Options collection decides what the rest of your workflow actually receives, and getting it right here saves a Code node later.

Key parameters

  • JSON Parse Body: n8n tries to parse the message into an object, which is what you want when devices publish JSON and you plan to read a field with {{ $json.temperature }}.
  • Only Message: returns the message property alone, without the surrounding structure. Convenient for a plain text payload you just want to forward.
  • Parallel Processing: messages are handled in parallel, or turned off, kept in the order they arrived.
When to use it
keep order when a sequence of readings tells a story, such as a counter or a state change. Parallel is fine for independent alerts.
Actions

What can the MQTT node do?

The MQTT node exposes one operation. For each one: the node as you configure it in n8n, the required fields, and our field notes.

01

Push messages to MQTT

execute

What you see in n8n

Notes & use cases

The node publishes a message on a topic, and the broker passes it to whatever subscribes there.

Key parameters

  • Topic: required, the topic to publish to, often built from an earlier node with {{ $json.device }}.
  • Message: required, the message to publish. Empty means the node stops.
  • Send Input Data: sends the data the node receives as JSON instead.
  • QoS: 0 received at most once, 1 at least once, 2 exactly once.
  • Retain: the broker keeps this last message on the topic.
Use cases
pushing a setpoint to a device topic after a workflow decides it has changed.
Need help

Need help automating MQTT with n8n?

A person reads every message.

FAQ

MQTT and n8n, the questions that come up

01Is the MQTT n8n integration free in n8n?
Yes. Both the MQTT node and the MQTT Trigger ship with n8n, so there is nothing to install and nothing extra to pay on the n8n side. That holds on n8n Cloud, the hosted offer run by n8n, and on a self-hosted instance under the Community Edition and its Sustainable Use licence. A workflow behaves the same either way, which matters here because self-hosting often puts n8n on the same network as the broker. What the broker itself costs depends on the one you install or subscribe to, and that is outside what n8n charges you for.
02What credentials does the MQTT node need?
One credential type, called broker connection, shared by the node and the trigger. You need the broker Protocol, which can be Mqtt, Mqtts or Ws, then the Host and the Port, then a Username and Password to authenticate with. If the broker uses SSL, you add the relevant certificates and keys: a Client Certificate with its Client Key for a passwordless connection, and one or more CA Certificates. The credential is created once in the Credentials menu and reused across every workflow, so both nodes pick it from a dropdown instead of repeating the connection details.
03What are the limits of the MQTT node in n8n?
The node has a single operation: publish a message to a topic. It does not read, it does not manage the broker, and everything that comes in arrives through the trigger instead. The bigger point is the fallback. On an integration built on an HTTP API, a missing operation usually means calling the endpoint yourself with a generic node. The MQTT credential opens a connection to a broker rather than an HTTP API, so that route does not exist. What the two nodes expose is the whole surface available from n8n, and anything else has to happen on the broker side.
04Does the MQTT Trigger react in real time?
No promise on that front, and it would be dishonest to give you a number. n8n does not document a mechanism for the MQTT Trigger, so this page will not claim a delay, an interval, or anything about how the subscription is handled underneath. What is documented is simpler: the workflow has to be active for the trigger to listen on its topics, and nothing is captured while it sits inactive. One related setting helps: turning Clean Session off in the credential lets you receive QoS 1 and 2 messages that were published while the connection was down.
05n8n or Make for MQTT?
It depends on where your broker lives and how you want to pay. Make is a hosted automation platform with no self-hosting option, billed per operation, which is a real consideration when devices publish steadily and every message is an operation. n8n runs on n8n Cloud or on your own server, so it can sit on the same network as a broker that never faces the public internet. Both give you a visual canvas, and the honest tiebreakers are data control, the cost model against your message volume, and how comfortable your team is running infrastructure.
Hack'celeration Lab

Get our weekly integration tips.

No spam. Unsubscribe anytime.