# Publishing messages to an MQTT topic

1. Open Node-RED.
2. Add an mqtt node from the output category to the workspace.
3. Connect the input of the mqtt node to the output of the node whose output you want to publish.
4. Double-click the mqtt node to open the Edit node dialogue.
5. In the drop-down list Server, select a server to connect to or add a new MQTT broker.

6. ## NOTICE

   You can set topic, QoS and retain dynamically via message properties by leaving the corresponding fields blank.

7. In the text box Topic, enter the topic you want the node to publish to.
8. In the drop-down list QoS, select the Quality of Service level. Choose from:

9. ## NOTICE

   0 (fire and forget): Arrival of the message solely relies on the underlying Internet Protocol network. Message loss may occur.

   1 (at least once): The message is assured to arrive, but may arrive more than once.

   2 (once and once only): The message is assured to arrive once and only once.

10. In the drop-down list Retain, select whether messages shall be retained on the broker.
11. Click Done to apply your changes.