Message object
Message
is an object that refers to a single message published on a chat channel.
Properties
The Message
object has the following properties:
class Message {
timetoken: string,
content: TextMessageContent,
channelId: string,
userId: string,
actions?: MessageActions,
meta?: {
[key: string]: any
}
}
Parameter | Type | Description |
---|---|---|
timetoken | string | Unique identifier for the message, possibly a timestamp or similar value that helps order messages in a conversation. |
content | TextMessageContent | Original text content of the message. |
channelId | string | Unique identifier for the channel or group in which the message was sent. |
userId | string | Unique ID of the user who sent the message. |
actions | MessageActions or undefined | Any actions associated with the message, such as reactions, replies, or other interactive elements. |
meta | object or undefined | Extra information added to the message giving additional context. This object can be of any type and can consist of a list of key-value pairs. For example, {language: 'English', wordCount: 42} . |
The message and message reaction types defined for the Message
object take the following parameters:
TextMessageContent
type TextMessageContent = {
type: MessageType.TEXT;
text: string;
files?: {
name: string;
id: string;
url: string;
type?: string
}[]MessageActions
type MessageActions = {
[type: string]: {
[value: string]: {
uuid: string;
actionTimetoken: string | number;
}[];
};
}
A single text message has the text
type.
export enum MessageType {
TEXT = "text"
}
Depending on how a message was manipulated (what action was taken on it), it is assigned a different action type (for adding a message reaction to a message, editing, or deleting a message). For example, MessageActionType.EDITED
.
export enum MessageActionType {
REACTIONS = "reactions",
DELETED = "deleted",
EDITED = "edited",
}
Methods
You can call the following methods on the Message
object.
Click on each method for more details.
createThread()
delete()
- (getter)
deleted
editText()
forward()
getMessageElements()
getThread()
hasUserReaction()
toggleReaction()
pin()
- (getter)
quotedMessage
- (getter)
reactions
report()
streamUpdates()
- (static)
streamUpdatesOn()
- (getter)
text
- (getter)
textlinks
Use case
For example, you can use the Message
object methods to: