Skip to main content
The Message class represents a chat message with structured formatting (mdast AST), metadata, attachments, and platform-specific raw data. It supports serialization for workflow engines.

Constructor

MessageData<TRawMessage>
required
Message data object
Message<TRawMessage>
Message instance

Properties

id

Unique message ID.

threadId

Thread this message belongs to.

text

Plain text content with all formatting stripped.

formatted

Structured formatting as an mdast AST (Root). This is the canonical representation - use this for processing.
Use stringifyMarkdown(message.formatted) from the chat package to convert the AST back to a markdown string.

raw

Platform-specific raw payload. Use this as an escape hatch when you need to access platform-specific fields not exposed by the normalized Message interface.

author

Message author information.
Author

metadata

Message metadata including timestamps and edit status.
MessageMetadata

attachments

Files, images, videos, or audio attached to the message.
Attachment

isMention

Whether the bot is @-mentioned in this message.
This is set by the Chat SDK before passing the message to handlers. It checks for @username in the message text using the adapter’s configured userName and optional botUserId.

Methods

toJSON()

Serialize the message to a plain JSON object. Use this to pass message data to external systems like workflow engines.
SerializedMessage
Serialized message with dates as ISO strings
Attachment data (Buffer) and fetchData (function) are omitted as they’re not serializable.

Static Methods

fromJSON()

Reconstruct a Message from serialized JSON data. Converts ISO date strings back to Date objects.
SerializedMessage
required
Serialized message data
Message<TRawMessage>
Reconstructed Message instance

Type Parameters

unknown
default:"unknown"
Platform-specific raw message type

Usage Examples

Accessing Message Content

Checking for Mentions

Processing Attachments

Working with Formatted Content

Serialization for Workflows

Platform-Specific Data

See Also