💎 ChatSDK Ruby

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:
)
ParameterTypeRequiredDefaultDescription
idStringYes--Channel identifier
adapterAdapter::BaseYes--The platform adapter
chatChatYes--The parent Chat instance

Channels are typically created via Chat#channel or Chat#open_dm rather than directly.

Attributes

AttributeTypeDescription
idStringChannel identifier
adapterAdapter::BaseThe platform adapter
chatChatThe 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" })
ParameterTypeRequiredDescription
contentString, Cards::Node, or PostableMessageYesMessage 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")
ParameterTypeRequiredDescription
thread_idStringYesThread 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.

On this page