Skip to content
// EFFECT DAYS 2026

ChatMessage unstable

Messages read from a chat platform.

A ChatMessage has the same shape on every read path: inbound events, Chat.fetchMessage and Chat.history. Its text is the platform's own content string, verbatim, and its mentions are data with offsets into that text.

12 exports Since v4.1.5 Source

Models

Attachment

type unstable
Since v4.1.5

A file attached to a message.

Signature

type Attachment = typeof Attachment.Type

Author

type unstable
Since v4.1.5

The author of a message.

Signature

type Author = typeof Author.Type

ChatMessage

type unstable
Since v4.1.5

A message read from a chat platform.

Signature

type ChatMessage = typeof ChatMessage.Type

Mention

type unstable
Since v4.1.5

A mention inside a message's text.

Signature

type Mention = typeof Mention.Type

ReplyTo

type unstable
Since v4.1.5

The message a message replies to.

Signature

type ReplyTo = typeof ReplyTo.Type

Predicates

Since v4.1.5

Returns whether the message mentions the bot.

Gotchas

A reply to the bot is not a mention. Whether it counts as one is the consumer's policy.

See

Signature

declare function mentionsSelf(message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}): boolean
Since v4.1.5

Returns whether the message replies to one of the bot's own messages.

When to use

Use with mentionsSelf when a reply to the bot should count as addressed to it, whether or not the reply pings.

Gotchas

  • It reads replyTo.isSelf, so it is false when the platform does not say who wrote the message replied to.
  • A message in a Slack thread is not a reply to the thread's first message: Slack messages carry no replyTo.

See

Signature

declare function repliesToSelf(message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}): boolean

Schemas

Attachment

unstable
Since v4.1.5

Schema for a file attached to a message.

Gotchas

An attachment never carries a URL. Chat.download resolves the id again.

Signature

declare const Attachment: Struct<{
readonly contentType: optionalKey<String>;
readonly id: String;
readonly name: optionalKey<String>;
readonly size: optionalKey<Int>;
}>

Author

unstable
Since v4.1.5

Schema for the author of a message.

Details

name is a best-effort display name: whatever the payload carries. There is no lookup, so inbound messages and history can differ. Other bots' messages are delivered with isBot: true; isSelf marks the bot's own.

Signature

declare const Author: Struct<{
readonly id: String;
readonly isBot: Boolean;
readonly isSelf: Boolean;
readonly name: optionalKey<String>;
}>

ChatMessage

unstable
Since v4.1.5

Schema for a message read from a chat platform.

Details

  • thread is the address the message was posted to, the same on every read path. It never changes: a message a thread hangs off stays in the parent, also once it has replies. Chat.startThread(message.thread, message.id) is the way from such a message to its thread.
  • text is the platform's own content string, verbatim, with mention tokens and code fences in place. One exception: Slack renders the bot's own messages with rich_text blocks from those blocks as Markdown.
  • raw is the platform's message payload, as a JSON value.

Gotchas

text is a different format from outbound Markdown and cannot be posted back as is.

Signature

declare const ChatMessage: Struct<{
readonly attachments: $Array<Struct<{
readonly contentType: optionalKey<String>;
readonly id: String;
readonly name: optionalKey<String>;
readonly size: optionalKey<Int>;
}>>;
readonly author: Struct<{
readonly id: String;
readonly isBot: Boolean;
readonly isSelf: Boolean;
readonly name: optionalKey<String>;
}>;
readonly id: String;
readonly mentions: $Array<Struct<{
readonly end: Int;
readonly id: String;
readonly isSelf: Boolean;
readonly kind: Literals<readonly ["user", "role", "channel", "broadcast"]>;
readonly start: Int;
}>>;
readonly raw: Codec<Json, Json, never, never>;
readonly replyTo: optionalKey<Struct<{
readonly authorId: optionalKey<String>;
readonly isSelf: optionalKey<Boolean>;
readonly messageId: String;
}>>;
readonly text: String;
readonly thread: Struct<{
readonly id: String;
readonly platform: String;
}>;
readonly timestamp: DateTimeUtc;
}>

Mention

unstable
Since v4.1.5

Schema for a mention inside a message's text.

Details

start and end are offsets into ChatMessage.text, in UTF-16 code units, so text.slice(start, end) is the platform's own token for the mention. id is the platform id, or here, channel or everyone for a broadcast.

Signature

declare const Mention: Struct<{
readonly end: Int;
readonly id: String;
readonly isSelf: Boolean;
readonly kind: Literals<readonly ["user", "role", "channel", "broadcast"]>;
readonly start: Int;
}>

ReplyTo

unstable
Since v4.1.5

Schema for the message a message replies to.

Details

  • authorId is there when the platform says who wrote the message replied to. Discord leaves it out once that message is deleted.
  • isSelf says whether that author is the bot. An adapter sets it on every message it reads that has an authorId. A write ignores both.

Signature

declare const ReplyTo: Struct<{
readonly authorId: optionalKey<String>;
readonly isSelf: optionalKey<Boolean>;
readonly messageId: String;
}>