The Message class represents a single SMS/MMS message in the RELAY messaging
namespace. It tracks the lifecycle of a sent or received message through state
events. Outbound messages progress through queued, initiated, sent, and
then reach a terminal state (delivered, undelivered, or failed). Inbound
messages arrive fully formed with state received.
Obtain a Message instance from RelayClient.sendMessage()
or from the client.onMessage() handler for inbound messages.
Unique identifier for this message, assigned by SignalWire.
The messaging context this message belongs to.
Message direction. Valid values:
"inbound" — incoming message"outbound" — outgoing messageSender phone number in E.164 format.
Recipient phone number in E.164 format.
Text content of the message.
List of media URLs for MMS messages. Empty list for SMS-only messages.
Number of SMS segments required for this message.
Current message state. See Message Constants for valid values.
"queued" — message has been accepted and is waiting to be processed"initiated" — message processing has started"sent" — message has been dispatched to the carrier"delivered" — message was successfully delivered to the recipient"undelivered" — carrier was unable to deliver the message"failed" — message could not be sent"received" — inbound message received from the networkFailure reason when the message reaches an error state. Empty string if no failure has occurred.
Optional tags associated with this message.
true if the message has reached a terminal state (delivered, undelivered, or failed).
Read-only property.
The terminal RelayEvent that resolved this message,
or null if the message has not yet completed.
Events are emitted during the lifecycle of a message. Register handlers using
message.on() to react to state changes on outbound messages.
See the Events reference for the full list of messaging events, their parameters, and typed event classes.
Register an event listener for state changes on this message.
Block until the message reaches a terminal state.