Skip to main content

Properties

string
Bot user ID for platforms that use IDs in mentions (e.g., Slack’s <@U123>)
Default lock scope for this adapter.
  • 'thread' (default): lock per threadId
  • 'channel': lock per channelId (for channel-based platforms like WhatsApp, Telegram)
Can be overridden by ChatConfig.lockScope.
string
required
Unique name for this adapter (e.g., “slack”, “teams”)
boolean
boolean
When true, the SDK persists per-thread message history in the state adapter for this platform. Use for platforms that lack server-side message history APIs (e.g. WhatsApp, Telegram).
boolean
Whether active turns should be published for cross-process cancellation.
string
required
Bot username (can override global userName)

Methods

addReaction()

Add a reaction to a message

Parameters

string
required
string
required
string | EmojiValue
required

Returns

Promise<void>

channelIdFromThreadId()

Derive channel ID from a thread ID. Default fallback: first two colon-separated parts (e.g., “slack:C123”). Adapters with different structures should override this.

Parameters

string
required

Returns

string

decodeThreadId()

Decode thread ID string back to platform-specific data

Parameters

string
required

Returns

TThreadId

deleteMessage()

Delete a message

Parameters

string
required
string
required

Returns

Promise<void>

disconnect()

Cleanup hook called when Chat instance is shutdown

Returns

Promise<void>

editMessage()

Edit an existing message

Parameters

string
required
string
required

Returns

RawMessage

editObject()

Edit a previously posted object (Plan, Poll, etc.). If not implemented, object updates will throw PlanNotSupportedError.

Parameters

string
required
The thread containing the message
string
required
The message ID to edit
string
required
The object kind (e.g., “plan”)
unknown
required
The object data (type depends on kind)

Returns

RawMessage

encodeThreadId()

Encode platform-specific data into a thread ID string

Parameters

TThreadId
required

Returns

string

endTyping()

Clear a typing/processing indicator after a reply finishes. Optional because most platforms clear typing indicators automatically. Agent-session platforms can implement this to transition the session back to an active state.

Parameters

string
required

Returns

Promise<void>

fetchChannelInfo()

Fetch channel info/metadata.

Parameters

string
required

Returns

ChannelInfo

fetchChannelMessages()

Fetch channel-level messages (top-level, not thread replies). For example, Slack’s conversations.history vs conversations.replies.

Parameters

string
required

Returns

FetchResult

fetchMessage()

Fetch a single message by ID. Optional - adapters that don’t implement this will return null.

Parameters

string
required
The thread ID containing the message
string
required
The platform-specific message ID

Returns

Message The message, or null if not found/not supported

fetchMessages()

Fetch messages from a thread. Direction behavior:
  • backward (default): Fetches the most recent messages. Use this for loading a chat view. The nextCursor points to older messages.
  • forward: Fetches the oldest messages first. Use this for iterating through message history. The nextCursor points to newer messages.
Message ordering: Messages within each page are always returned in chronological order (oldest first), regardless of direction. This is the natural reading order for chat messages.

Parameters

string
required

Returns

FetchResult

fetchSubject()

Parameters

TRawMessage
required

Returns

MessageSubject

fetchThread()

Fetch thread metadata

Parameters

string
required

Returns

ThreadInfo

getChannelVisibility()

Get the visibility scope of a channel containing the thread. This distinguishes between private channels, workspace-visible channels, and externally shared channels (e.g., Slack Connect).

Parameters

string
required
The thread ID to check

Returns

ChannelVisibility The channel visibility scope

getUser()

Look up user information by user ID. Optional — not all platforms support this.

Parameters

string
required
Platform-specific user ID

Returns

UserInfo User info, or null if user not found

handleWebhook()

Handle incoming webhook request

Parameters

Request
required

Returns

Promise<Response>

initialize()

Called when Chat instance is created (internal use)

Parameters

required

Returns

Promise<void>

isDM()

Check if a thread is a direct message conversation.

Parameters

string
required
The thread ID to check

Returns

boolean True if the thread is a DM, false otherwise

listThreads()

List threads in a channel.

Parameters

string
required

Returns

ListThreadsResult

markAsRead()

Send a read receipt for an inbound message. Optional: Thread.markAsRead() throws NotImplementedError when an adapter leaves this out. The full message is passed alongside its ID when the caller has one, so adapters can read platform data off message.raw instead of resolving the ID themselves.

Parameters

string
required
Thread containing the message
string
required
ID of the message to acknowledge
Message<TRawMessage>
Type: MessageThe message itself, when the caller has it

Returns

Promise<void>

onThreadSubscribe()

Optional hook called when a thread is subscribed to. Adapters can use this to set up platform-specific subscriptions (e.g., Google Chat Workspace Events).

Parameters

string
required

Returns

Promise<void>

openDM()

Open a direct message conversation with a user.

Parameters

string
required
The platform-specific user ID

Returns

Promise<string> The thread ID for the DM conversation

openModal()

Open a modal/dialog form.

Parameters

string
required
Platform-specific trigger ID from the action event
The modal element to display
string
Optional context ID for server-side stored thread/message context

Returns

Promise<{ viewId: string }> The view/dialog ID

parseMessage()

Parse platform message format to normalized format

Parameters

TRawMessage
required

Returns

Message

postChannelMessage()

Post a message to channel top-level (not in a thread).

Parameters

string
required

Returns

RawMessage

postEphemeral()

Post a message visible only to a specific user, natively or via an explicit fallback. This is optional - if not implemented, Thread.postEphemeral will fall back to openDM + postMessage when fallbackToDM is true.

Parameters

string
required
The thread to post in
string
required
The user who should see the message
The message content

Returns

EphemeralMessage EphemeralMessage with usedFallback indicating private delivery, or null if unsupported

postMessage()

Post a message to a thread

Parameters

string
required

Returns

RawMessage

postObject()

Post a special object (Plan, Poll, etc.) as a single message. If not implemented, posting such objects will throw PlanNotSupportedError.

Parameters

string
required
The thread to post to
string
required
The object kind (e.g., “plan”)
unknown
required
The object data (type depends on kind)

Returns

RawMessage

rehydrateAttachment()

Reconstruct fetchData on an attachment after deserialization. Called during message rehydration for queue/debounce strategies. Uses fetchMetadata and adapter auth context to rebuild the download closure.

Parameters

required

Returns

Attachment

removeReaction()

Remove a reaction from a message

Parameters

string
required
string
required
string | EmojiValue
required

Returns

Promise<void>

renderFormatted()

Render formatted content to platform-specific string

Parameters

required

Returns

string

reply()

Parameters

string
required
string
required

Returns

RawMessage

scheduleMessage()

Schedule a message for future delivery. Optional — only supported by adapters with native scheduling APIs (e.g., Slack). Thread.schedule() will throw NotImplementedError if this method is absent.

Parameters

string
required
The thread to post in
The message content
{ postAt: Date }
required
Scheduling options including the target delivery time

Returns

ScheduledMessage A ScheduledMessage with cancel() capability

startTyping()

Show typing indicator

Parameters

string
required
string

Returns

Promise<void>

stream()

Stream a message using platform-native streaming APIs. The adapter consumes the async iterable and handles the entire streaming lifecycle. Available on platforms with native streaming or preview APIs. Adapters may return null before consuming any chunks to delegate back to Chat SDK’s built-in post+edit fallback for the current thread. The stream can yield plain strings (text chunks) or StreamChunk objects for rich content like task progress cards. Adapters that don’t support structured chunks will extract text from markdown_text chunks and ignore other types.

Parameters

string
required
The thread to stream to
AsyncIterable<string | StreamChunk>
required
Type: StreamChunkAsync iterable of text chunks or structured StreamChunk objects
Platform-specific streaming options

Returns

RawMessage The raw message after streaming completes, or null to use core fallback