Nats Trigger icon

Nats Trigger

Consume messages from a Nats subject

Overview

The Nats Trigger node listens for messages on a specified NATS subject and queue, emitting each received message into your n8n workflow. This node is useful for integrating real-time data streams or event-driven architectures with n8n, such as:

  • Reacting to events published by microservices via NATS.
  • Consuming messages from distributed systems for further processing in n8n.
  • Building automations that trigger on external system notifications.

Example use cases:

  • Automatically process new orders when an order service publishes to a "orders" subject.
  • Monitor IoT device updates sent to a specific NATS subject and trigger alerts or data storage workflows.

Properties

Name Type Meaning
Subject String Name of the NATS subject (queue/topic) to consume messages from.
Queue String The queue group name for load-balanced message consumption (default: n8n_queue).

Output

Each time a message is received on the specified subject and queue, the node emits an item with the following structure:

{
  "json": {
    // Decoded JSON content of the NATS message
    // Structure depends on what was published to the subject
  }
}
  • The output's json field contains the decoded JSON payload of the incoming NATS message.
  • No binary data is emitted by this node.

Dependencies

  • External Service: Requires access to a running NATS server/cluster.
  • Credentials: You must configure NATS credentials (natsApi) in n8n, including:
    • Servers (comma-separated list)
    • Optional authentication (username & password)
  • n8n Configuration: Ensure the node has network access to the NATS servers.

Troubleshooting

Common Issues:

  • Authentication Errors:
    If username/password are required but not provided, you will see:
    "Username and password are required for authentication"
    Resolution: Check your NATS credentials configuration in n8n.

  • Connection Failures:
    If the node cannot connect to the NATS server(s), ensure:

    • The server addresses are correct and reachable.
    • Network/firewall settings allow connections.
    • Credentials are valid.
  • No Messages Received:

    • Verify the subject and queue names match those used by publishers.
    • Ensure messages are being published to the expected subject.

Links and References

Discussion