Package com.tnsai.channels.api
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 identifiersenderName- human-readable sender name (display name or username)conversationId- platform-specific chat/channel/thread identifiertext- message text content (may be null for media-only messages)attachments- files, images, voice notes attached to the messagemeta- 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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionUnifiedMessage(String channelId, String senderId, String senderName, String conversationId, String text, List<Attachment> attachments, MessageMeta meta, Instant timestamp) Creates an instance of aUnifiedMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattachmentsrecord component.static UnifiedMessage.Builderbuilder()Returns the value of thechannelIdrecord component.Returns the value of theconversationIdrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.meta()Returns the value of themetarecord component.scopedId()Convenience: typed identity for "this user, on this channel".senderId()Returns the value of thesenderIdrecord component.Returns the value of thesenderNamerecord component.Convenience: unique session key combining channel and conversation.text()Returns the value of thetextrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
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 aUnifiedMessagerecord class.- Parameters:
channelId- the value for thechannelIdrecord componentsenderId- the value for thesenderIdrecord componentsenderName- the value for thesenderNamerecord componentconversationId- the value for theconversationIdrecord componenttext- the value for thetextrecord componentattachments- the value for theattachmentsrecord componentmeta- the value for themetarecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
sessionKey
Convenience: unique session key combining channel and conversation. -
scopedId
Convenience: typed identity for "this user, on this channel". Equivalent tonew 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 oneChannelScopedIdbut two distinctsessionKeys. -
builder
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
channelId
Returns the value of thechannelIdrecord component.- Returns:
- the value of the
channelIdrecord component
-
senderId
Returns the value of thesenderIdrecord component.- Returns:
- the value of the
senderIdrecord component
-
senderName
Returns the value of thesenderNamerecord component.- Returns:
- the value of the
senderNamerecord component
-
conversationId
Returns the value of theconversationIdrecord component.- Returns:
- the value of the
conversationIdrecord component
-
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
attachments
Returns the value of theattachmentsrecord component.- Returns:
- the value of the
attachmentsrecord component
-
meta
Returns the value of themetarecord component.- Returns:
- the value of the
metarecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-