Channel
Channel container that holds threads, with methods for listing, posting, and iteration.
A Channel represents a channel or conversation container that holds threads. Both Thread and Channel extend the shared Postable interface, so they share common methods like post(), state, and messages.
Get a channel via thread.channel or chat.channel():
// Navigate from a thread
const channel = thread.channel;
// Get directly by ID
const channel = chat.channel("slack:C123ABC");Properties
Prop
Type
Channel ID format
Channel IDs are derived from thread IDs by dropping the thread-specific part. By default, this is the first two colon-separated segments:
| Platform | Thread ID | Channel ID |
|---|---|---|
| Slack | slack:C123ABC:1234567890.123456 | slack:C123ABC |
| Teams | teams:{base64}:{base64} | teams:{base64} |
| Google Chat | gchat:spaces/ABC123:{base64} | gchat:spaces/ABC123 |
| Discord | discord:{guildId}:{channelId}/{messageId} | discord:{guildId} |
messages
Iterate channel-level messages (top-level, not thread replies) newest first. Auto-paginates lazily.
for await (const msg of channel.messages) {
console.log(msg.text);
}threads
Iterate threads in the channel, most recently active first. Returns lightweight ThreadSummary objects.
for await (const thread of channel.threads()) {
console.log(thread.rootMessage.text, thread.replyCount);
}ThreadSummary
Prop
Type
post
Post a message to the channel top-level (not in a thread).
await channel.post("Hello channel!");
await channel.post({ markdown: "**Announcement**: New release!" });Accepts the same message formats as thread.post() — see PostableMessage.
fetchMetadata
Fetch channel metadata from the platform.
const info = await channel.fetchMetadata();
console.log(info.name, info.memberCount);ChannelInfo
Prop
Type
state
Store typed, per-channel state. Works the same as thread state with a 30-day TTL.
const state = await channel.state;
await channel.setState({ lastAnnouncement: new Date().toISOString() });postEphemeral
Post a message visible only to a specific user.
await channel.postEphemeral(userId, "Only you can see this", {
fallbackToDM: true,
});startTyping
Show a typing indicator. No-op on platforms that don't support it.
await channel.startTyping();mentionUser
Get a platform-specific @-mention string.
await channel.post(`Hey ${channel.mentionUser(userId)}, check this out!`);