API: Channel
ChatSDK::Channel represents a chat channel and provides methods for posting messages and accessing threads.
ChatSDK::Channel represents a chat channel. It provides methods for posting top-level messages and creating Thread objects for threaded conversations.
Constructor
ChatSDK::Channel.new(
id:,
adapter:,
chat:
)| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | String | Yes | -- | Channel identifier |
adapter | Adapter::Base | Yes | -- | The platform adapter |
chat | Chat | Yes | -- | The parent Chat instance |
Channels are typically created via Chat#channel or Chat#open_dm rather than directly.
Attributes
| Attribute | Type | Description |
|---|---|---|
id | String | Channel identifier |
adapter | Adapter::Base | The platform adapter |
chat | Chat | The parent Chat instance |
Instance Methods
post(content)
Posts a top-level message to the channel (not in a thread). Accepts a String, Cards::Node, or PostableMessage.
channel = chat.channel("C123")
channel.post("Hello, channel!")
channel.post(ChatSDK.card(title: "Alert") { text "Something happened" })| Parameter | Type | Required | Description |
|---|---|---|---|
content | String, Cards::Node, or PostableMessage | Yes | Message content to post |
Returns the result from the adapter's post_message.
thread(thread_id)
Returns a Thread object bound to this channel.
thread = channel.thread("T456")
thread.post("Replying in the thread")| Parameter | Type | Required | Description |
|---|---|---|---|
thread_id | String | Yes | Thread identifier |
Returns a ChatSDK::Thread instance.
Equality
Two channels are equal (==, eql?) if they have the same id. The hash method is consistent with equality, making channels usable as hash keys.