Skip to main content
The Chat SDK organizes conversations around three core concepts: Threads, Messages, and Channels. Understanding how these work together is essential for building chat applications.

Thread

A Thread represents a conversation context where messages are exchanged. It’s the primary interface for posting messages, managing state, and subscribing to updates.

Thread ID Format

Thread IDs follow the pattern: {adapter}:{channel}:{thread}

Custom Thread State

Threads support type-safe custom state with automatic persistence:
State is persisted for 30 days by default using THREAD_STATE_TTL_MS.

Message

A Message represents a single chat message with normalized content across platforms.

Author Information

Message Metadata

Formatted Content

Messages use mdast (Markdown AST) as the canonical format:

Attachments

For platforms like Slack with private URLs, use fetchData() to automatically handle authentication.

Channel

A Channel represents a conversation container that holds threads and messages.

Getting a Channel

Listing Threads

On platforms without native threading (like standalone channels), threads() returns an empty iterable.

Channel Metadata

Relationship Between Concepts

Message Iteration Patterns

Thread Messages (Newest First)

Thread Messages (Oldest First)

Recent Messages (Cached)

Use recentMessages for quick access without pagination. Messages are cached when the thread is created or after calling refresh().