Skip to main content

Constructor

Parameters

MessageData<TRawMessage>
required

Returns

Message

Properties

Attachment[]
required
Type: AttachmentAttachments
required
Message author
required
Structured formatting as an AST (mdast Root). This is the canonical representation - use this for processing. Use stringifyMarkdown(message.formatted) to get markdown string.
string
required
Unique message ID
boolean
Whether the bot is @-mentioned in this message.Populated by the Chat SDK before handlers run. An adapter that reads the platform’s own mention metadata reports true or false; the SDK falls back to matching @username in the message text (using the adapter’s configured userName and optional botUserId) only when this is undefined.A definitive false wins over text that merely looks like a mention, such as @username inside a code sample or quoted text.One exception: a direct message received while no onDirectMessage handler is registered is always marked true, whatever the adapter reported, so it routes to onNewMention.
Type: LinkPreviewLinks found in the message
Message metadata
TRawMessage
required
Platform-specific raw payload (escape hatch)
Message<TRawMessage>
Type: MessageMessage this message replies to
Promise<MessageSubject | null>
required
string
required
Plain text content (all formatting stripped)
string
required
Thread this message belongs to
string
Cross-platform user key for this message’s author.Set by the Chat SDK before passing the message to handlers, when ChatConfig.identity is configured. undefined if no resolver is configured; undefined (i.e. absent) when the resolver returned null.Used by the Transcripts API to look up / append per-user transcripts.

Methods

WORKFLOW_DESERIALIZE

Deserialize a Message from @workflow/serde. This static method is automatically called by workflow deserialization.

Parameters

Returns

Message

WORKFLOW_SERIALIZE

Serialize a Message instance for @workflow/serde. This static method is automatically called by workflow serialization.

Parameters

required

Returns

SerializedMessage

fromJSON()

Reconstruct a Message from serialized JSON data. Converts ISO date strings back to Date objects.

Parameters

Returns

Message

toJSON()

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

Returns

SerializedMessage