Record Class UnifiedMessage

java.lang.Object
java.lang.Record
com.tnsai.channels.api.UnifiedMessage
Record Components:
channelId - adapter id that produced this message (e.g. "telegram")
senderId - platform-specific user identifier
senderName - human-readable sender name (display name or username)
conversationId - platform-specific chat/channel/thread identifier
text - message text content (may be null for media-only messages)
attachments - files, images, voice notes attached to the message
meta - optional platform-specific metadata (reply-to, thread id, etc.)
timestamp - when the message was sent

public record UnifiedMessage(String channelId, String senderId, String senderName, String conversationId, String text, List<Attachment> attachments, MessageMeta meta, Instant timestamp) extends Record
Platform-agnostic inbound message. Every channel adapter converts its native message format into this record before handing it to the gateway.
  • Constructor Details

    • UnifiedMessage

      public UnifiedMessage(String channelId, String senderId, String senderName, String conversationId, String text, List<Attachment> attachments, MessageMeta meta, Instant timestamp)
      Creates an instance of a UnifiedMessage record class.
      Parameters:
      channelId - the value for the channelId record component
      senderId - the value for the senderId record component
      senderName - the value for the senderName record component
      conversationId - the value for the conversationId record component
      text - the value for the text record component
      attachments - the value for the attachments record component
      meta - the value for the meta record component
      timestamp - the value for the timestamp record component
  • Method Details

    • sessionKey

      public String sessionKey()
      Convenience: unique session key combining channel and conversation.
    • scopedId

      public ChannelScopedId scopedId()
      Convenience: typed identity for "this user, on this channel". Equivalent to new ChannelScopedId(channelId(), senderId()) but reads at the call site like the intent.

      Note this is sender-scoped (one identity per user), complementing sessionKey() which is conversation-scoped (one identity per chat). A user reaching the agent from two different conversations on the same channel has one ChannelScopedId but two distinct sessionKeys.

    • builder

      public static UnifiedMessage.Builder builder()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • channelId

      public String channelId()
      Returns the value of the channelId record component.
      Returns:
      the value of the channelId record component
    • senderId

      public String senderId()
      Returns the value of the senderId record component.
      Returns:
      the value of the senderId record component
    • senderName

      public String senderName()
      Returns the value of the senderName record component.
      Returns:
      the value of the senderName record component
    • conversationId

      public String conversationId()
      Returns the value of the conversationId record component.
      Returns:
      the value of the conversationId record component
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • attachments

      public List<Attachment> attachments()
      Returns the value of the attachments record component.
      Returns:
      the value of the attachments record component
    • meta

      public MessageMeta meta()
      Returns the value of the meta record component.
      Returns:
      the value of the meta record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component