Thread interface represents a conversation thread where users exchange messages. It provides methods for posting messages, managing subscriptions, and storing per-thread state.
Properties
id
{adapter}:{channel}:{thread}
Examples:
- Slack:
slack:C123ABC:1234567890.123456 - Teams:
teams:{base64(conversationId)}:{base64(serviceUrl)} - Google Chat:
gchat:spaces/ABC123:{base64(threadName)}
channelId
adapter
isDM
channel
state
recentMessages
refresh().
messages
allMessages
Methods
post()
string | PostableMessage | CardJSXElement
required
Message content to post
SentMessage
A SentMessage with methods to edit, delete, or add reactions
postEphemeral()
string | Author
required
User ID string or Author object (from message.author or event.user)
AdapterPostableMessage | CardJSXElement
required
Message content (string, markdown, card, etc.). Streaming is NOT supported.
PostEphemeralOptions
required
EphemeralMessage | null
EphemeralMessage with
usedFallback: true if DM was used, or null if native ephemeral not supported and fallbackToDM is false- Slack: Native ephemeral (session-dependent, disappears on reload)
- Google Chat: Native private message (persists, only target user sees it)
- Discord: No native support - requires fallbackToDM: true
- Teams: No native support - requires fallbackToDM: true
setState()
Partial<TState>
required
State object to set (will be merged with existing state unless replace: true)
object
subscribe()
onSubscribedMessage handlers.
The initial message that triggered subscription will NOT fire the handler. Only subsequent messages will.
unsubscribe()
onSubscribedMessage handlers.
isSubscribed()
In subscribed message handlers, this is optimized to return true immediately without a state lookup, since we already know we’re in a subscribed context.
startTyping()
string
Optional status text (e.g., “Typing…”, “Searching documents…”) shown where supported
Some platforms support persistent typing indicators, others just send once. The optional status parameter is shown where supported.
refresh()
recentMessages from the API. Fetches the latest 50 messages and updates the cache.
mentionUser()
string
required
Platform-specific user ID
string
Formatted mention string (e.g.,
<@U123>)createSentMessageFromMessage()
Message
required
Message object to wrap
SentMessage
SentMessage with edit/delete/reaction methods
Type Parameters
object
default:"Record<string, unknown>"
Custom state type stored per-thread
unknown
default:"unknown"
Platform-specific raw message type
Usage Examples
Basic Message Posting
Streaming from AI
Thread State Management
Message Iteration
See Also
- Chat API - Main Chat class
- Channel API - Channel interface
- Message API - Message structure
- State Management - Thread state details
- Formatting - Markdown and rich formatting