Overview
This node acts as a WebSocket trigger for Mira backend events. It connects to a Mira WebSocket server and listens for real-time event messages, which it then emits to trigger workflows in n8n. This is useful for automating processes based on live updates from the Mira system, such as reacting to file changes or other system events.
Common scenarios include:
- Automatically processing files when they are created or updated in Mira.
- Triggering notifications or downstream workflows upon specific Mira events.
- Monitoring Mira system activity in real time for auditing or logging purposes.
For example, you could configure this node to listen for file::created and file::updated events and start a workflow that processes those files immediately after they appear or change.
Properties
| Name | Meaning |
|---|---|
| Mira WebSocket URL | The WebSocket endpoint URL of the Mira backend to connect to (e.g., ws://127.0.0.1:7457). |
| Authentication Token | A token used to authenticate the WebSocket connection with the Mira backend. |
| Event Filter | Comma-separated list of event names to listen for (e.g., file::created,file::updated). If empty, all events are received. |
| Advanced Options | Collection of optional settings: |
| - Reconnect Initial Delay (ms) | Initial delay before attempting to reconnect after connection loss (default 1000 ms). |
| - Reconnect Max Delay (ms) | Maximum delay between reconnection attempts (default 30000 ms). |
| - Enable Debug Logging | Enables detailed console logging for debugging purposes (default false). |
Output
The node outputs JSON objects representing Mira WebSocket events. Each output item has the following structure:
{
"eventName": "string", // Name of the event, e.g., "file::created"
"data": {}, // Event-specific data payload
"timestamp": "ISO8601 string",// Timestamp of the event or reception time if not provided
"source": "mira_websocket" // Static identifier indicating the source of the event
}
Special cases:
- If a raw message cannot be parsed as JSON, an event with
eventName"raw_message"is emitted containing the raw text and a parse error flag. - On errors during message processing, an event with
eventName"error"is emitted including the error message. - Connection-related events such as
"connection_error"and"connection_closed"are also emitted with relevant details.
The node does not output binary data.
Dependencies
- Requires access to a Mira backend WebSocket server.
- Needs a valid authentication token for connecting to the Mira WebSocket endpoint.
- Uses the
wsWebSocket client library internally. - No additional n8n credentials or environment variables are required beyond the token input property.
Troubleshooting
- Connection failures: Ensure the WebSocket URL is correct and reachable. Verify the authentication token is valid.
- Event filtering: If no events are received, check the event filter string; it must match event names exactly or be left empty to receive all events.
- JSON parsing errors: If the Mira backend sends malformed JSON, the node will emit a raw message event with a parse error flag.
- Reconnection delays: The node automatically attempts to reconnect with exponential backoff between the configured initial and max delays.
- Debugging: Enable debug logging in advanced options to see detailed connection and message logs in the n8n console.
Common error messages:
"WebSocket error:"followed by a message indicates connection or protocol issues."Failed to parse JSON, treating as plain text"means the incoming message was not valid JSON."WebSocket closed:"indicates the connection was closed, possibly triggering reconnection.
Links and References
- WebSocket API Documentation
- Mira backend documentation (refer to your Mira system's official docs for event types and authentication)
- n8n WebSocket Trigger Node examples and best practices