Looking for the chatbot template? It's now here.

Message

Normalized message format with text, AST, author, and metadata.

Incoming messages are normalized across all platforms into a consistent Message object.

import { Message } from "chat";

Properties

Prop

Type

Author

Prop

Type

How isMe works

Each adapter detects whether a message came from the bot itself. The detection logic varies by platform:

PlatformDetection method
SlackChecks event.user === botUserId (primary), then event.bot_id === botId (for bot_message subtypes). Both IDs are fetched during initialization via auth.test.
TeamsChecks activity.from.id === appId (exact match), then checks if activity.from.id ends with :{appId} (handles 28:{appId} format).
Google ChatChecks message.sender.name === botUserId. The bot user ID is learned dynamically from message annotations when the bot is first @-mentioned.

All adapters return false if the bot ID isn't known yet. This is a safe default that prevents the bot from ignoring messages it should process.

MessageMetadata

Prop

Type

Attachment

Prop

Type

Serialization

Messages can be serialized for workflow engines and external systems.

// Serialize
const json = message.toJSON();

// Deserialize
const restored = Message.fromJSON(json);

The serialized format converts Date fields to ISO strings and omits non-serializable fields like data buffers and fetchData functions.

On this page

GitHubEdit this page on GitHub