Messages contain the data that a client is communicating, such as the contents of a chat message. Clients publish messages on channels, and these messages are received by clients that have subscribed to them. This pattern is otherwise known as pub/sub, as publishers and subscribers are completely decoupled.

The following are the properties of a message:

The name of the message.
The contents of the message. Also known as the message payload.
A unique ID assigned by Ably to each message.
The ID of the client that published the message.
The ID of the connection used to publish the message.
The timestamp of when the message was received by Ably, as milliseconds since the Unix epoch.
A JSON object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads. Valid payloads include those related to Push Notifications, deltas and message interactions, and headers.
This is typically empty, as all messages received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute contains the remaining transformations not applied to the data payload.

Message interactions enable you to interact with previously sent messages and support a wide variety of use cases. You can decide and customize what data is included in an interaction, and how this is displayed to end-users.

Message interactions can help you to implement:

  • Emoji reactions
  • Message updates and deletion
  • Read receipts and unread message counts
  • Quoting and replying to messages
  • Message threads
  • Media previews

Once a channel has message interactions enabled, messages received on that channel will contain a unique timeSerial that can be referenced by later messages.

Message interactions add a ref object to message payloads that enables you to indicate what an interaction represents, and which message it is referring to. The ref object contains two fields:

type (String)
a constant representing the reason for the interaction.
timeSerial (String)
a unique identifier used to reference a specific message, automatically generated when messages are sent in message interaction enabled channels.

Message interactions are only supported by the Ably JavaScript SDK.

Message properties