💎 ChatSDK Ruby

API: Message

ChatSDK::Message represents an incoming message from any platform, and ChatSDK::Author represents the user who sent it.

ChatSDK::Message represents an incoming message from any chat platform. ChatSDK::Author represents the user or bot that sent the message.

ChatSDK::Message

Constructor

ChatSDK::Message.new(
  id:,
  text:,
  author:,
  thread_id:,
  channel_id:,
  platform:,
  attachments: [],
  raw: nil,
  timestamp: nil
)
ParameterTypeRequiredDefaultDescription
idStringYes--Platform message ID
textStringYes--Message text content
authorAuthorYes--The message author
thread_idStringYes--Thread ID (may equal channel_id for top-level messages)
channel_idStringYes--Channel ID
platformSymbolYes--Platform identifier (e.g. :slack, :teams)
attachmentsArrayNo[]File or media attachments
rawObjectNonilRaw platform payload for advanced use
timestampTime or StringNonilMessage timestamp

Attributes

AttributeTypeDescription
idStringPlatform message ID
textStringMessage text content
authorAuthorThe message author
thread_idStringThread ID
channel_idStringChannel ID
platformSymbolPlatform identifier
attachmentsArrayFile or media attachments
rawObjectRaw platform payload
timestampTime or StringMessage timestamp

Equality

Two messages are equal (==, eql?) if they have the same id and platform. The hash method is consistent with equality.

msg_a == msg_b  # true when msg_a.id == msg_b.id && msg_a.platform == msg_b.platform

ChatSDK::Author

Constructor

ChatSDK::Author.new(
  id:,
  name:,
  platform:,
  bot: false,
  raw: nil
)
ParameterTypeRequiredDefaultDescription
idStringYes--Platform user ID
nameStringYes--Display name
platformSymbolYes--Platform identifier
botBooleanNofalseWhether this author is a bot
rawObjectNonilRaw platform user data

Attributes

AttributeTypeDescription
idStringPlatform user ID
nameStringDisplay name
platformSymbolPlatform identifier
rawObjectRaw platform user data

Instance Methods

bot?

Returns true if the author is a bot.

message.author.bot?  # => false

Equality

Two authors are equal (==, eql?) if they have the same id and platform. The hash method is consistent with equality.

On this page