Adapter interface defines the contract for integrating new chat platforms with Chat SDK. Each platform adapter handles webhook parsing, message formatting, and platform-specific API calls.
Built-in Adapters
Chat SDK provides adapters for:- @chat-adapter/slack - Slack
- @chat-adapter/teams - Microsoft Teams
- @chat-adapter/gchat - Google Chat
- @chat-adapter/discord - Discord
- @chat-adapter/telegram - Telegram
- @chat-adapter/github - GitHub
- @chat-adapter/linear - Linear
Interface Overview
Core Methods
name
string
required
Unique adapter name (e.g., “slack”, “teams”, “discord”)
userName
string
required
Bot username for this adapter
userName from ChatConfig.
handleWebhook()
Process incoming webhooks from the platform.Request
required
Standard Web Request object
WebhookOptions
Optional webhook handling options (waitUntil for background processing)
Response
HTTP response to return to the platform
initialize()
Called when the Chat instance is created. Use this to set up connections, validate credentials, etc.ChatInstance
required
The Chat instance
Thread ID Management
encodeThreadId()
Convert platform-specific thread data to a string ID.TThreadId
required
Platform-specific thread data structure
string
Encoded thread ID string
{adapter}:{channel}:{thread}
decodeThreadId()
Parse a thread ID string back to platform-specific data.string
required
Thread ID string
TThreadId
Platform-specific thread data structure
channelIdFromThreadId()
Extract channel ID from a thread ID. Optional - defaults to first two parts.string
required
Thread ID string
string
Channel ID
Messaging Methods
postMessage()
Post a message to a thread.string
required
Thread ID to post to
AdapterPostableMessage
required
Message content (string, markdown, AST, or card)
RawMessage<TRawMessage>
Platform response with message ID
editMessage()
Edit an existing message.string
required
Thread containing the message
string
required
Platform-specific message ID
AdapterPostableMessage
required
New message content
RawMessage<TRawMessage>
Updated message
deleteMessage()
Delete a message.string
required
Thread containing the message
string
required
Platform-specific message ID
renderFormatted()
Convert mdast AST to platform-specific format.FormattedContent
required
mdast Root node
string
Platform-specific formatted text
parseMessage()
Parse platform message to normalized Message object.TRawMessage
required
Platform-specific message object
Message<TRawMessage>
Normalized message
Optional Features
stream()
Stream AI responses using platform-native streaming (Slack only).string
required
Thread to stream to
AsyncIterable<string>
required
Text chunks to stream
StreamOptions
Platform-specific options
RawMessage<TRawMessage>
Final message after streaming completes
openDM()
Open a direct message conversation with a user.string
required
Platform-specific user ID
string
Thread ID for the DM
openModal()
Open a modal/dialog form.string
required
Platform trigger ID from action event
ModalElement
required
Modal element to display
string
Optional context ID for storing thread/message reference
{ viewId: string }
Platform-specific view/dialog ID