Message
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.send_message()
or from the @client.on_message handler for inbound messages.
Properties
message_id
Unique identifier for this message, assigned by SignalWire.
context
The messaging context this message belongs to.
direction
Message direction. Valid values:
"inbound"— incoming message"outbound"— outgoing message
from_number
Sender phone number in E.164 format.
to_number
Recipient phone number in E.164 format.
body
Text content of the message.
media
List of media URLs for MMS messages. Empty list for SMS-only messages.
segments
Number of SMS segments required for this message.
state
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 network
reason
Failure reason when the message reaches an error state. Empty string if no failure has occurred.
tags
Optional tags associated with this message.
is_done
True if the message has reached a terminal state (delivered, undelivered, or failed).
Read-only property.
result
The terminal RelayEvent that resolved this message,
or None if the message has not yet completed.
Events
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.
Methods
Register an event listener for state changes on this message.
Block until the message reaches a terminal state.