- Print
- DarkLight
- PDF
Message
- Print
- DarkLight
- PDF
The message object is the heart of a conversation. It encapsulates all the information needed in order to represent a single entry on a message list.
Messages are stored in the rocketchat_message
collection on MongoDB.
The IMessage
interface represents the structure of a message object in the Rocket.Chat It defines the properties and their types that can be associated with a message sent. You can check the IMessage
interface here.
Rocket.Chat/IMessage.ts at develop · RocketChat/Rocket.Chat
Message object
Example object
{
"_id": "8gMsLe9ApZjo2D2iB",
"rid": "EhpNtqqrMXT4QWk3z",
"msg": "This meesage is from Rocket.Chat.",
"ts": {
"$date": "2023-02-09T13:35:59.484Z"
},
"u": {
"_id": "rYhzFRd2QZjNwAAXX",
"username": "rodriq",
"name": "Rodriq"
},
"_updatedAt": {
"$date": "2023-02-09T13:40:47.334Z"
},
"urls": [],
"mentions": [],
"channels": [],
"md": [
{
"type": "PARAGRAPH",
"value": [
{
"type": "PLAIN_TEXT",
"value": "This meesage is from "
},
{
"type": "LINK",
"value": {
"src": {
"type": "PLAIN_TEXT",
"value": "//Rocket.Chat."
},
"label": {
"type": "PLAIN_TEXT",
"value": "Rocket.Chat."
}
}
}
]
}
],
"editedAt": {
"$date": "2023-02-09T13:40:47.303Z"
},
"editedBy": {
"_id": "rYhzFRd2QZjNwAAXX",
"username": "rodriq"
}
}
Fields
The message object contains these fields.
Parameter | Data type | Description |
---|---|---|
| String | The unique identifier for the message. |
| String | The unique ID for the room. This will identify the room that the message belongs to. Example: ' |
| String | The content of the message. |
| String | The ID of the thread to which the message belongs. |
| Boolean | Indicates whether the thread should be shown. |
| Date | A timestamp of when the message was created. (The date of creation on client) |
| Array of objects | An array of user mentions within the message. Identifies ( |
| Boolean | Boolean that states whether or not this message should be grouped together with other messages from the same user. |
| Array of objects | An array of channels to which the message belongs. |
| Object | The user who sent the message (either the _id or username or name). |
| MessageSurfaceLayout (enum) | If it is a UIkit message, then the UIkit blocks components. |
| String | An alias for the message sender. |
| Array of object | The message's content in a markdown format. |
| Boolean | Indicates whether the message is hidden. |
| Boolean | Indicates whether the message is imported. |
| Array of strings | An array of user IDs representing the message replies. |
| Object | The geographic location associated with the message. |
| Array of objects | A list of users that have the message starred (list of user IDs` (_id) |
| Boolean | Indicates whether the message is pinned. |
| Date | The date and time when the message was pinned. |
| Object | Information about the user who pinned the message. |
| Boolean | Indicates whether the message is unread. |
| Boolean | Indicates whether the message is temporary. |
| String | The direct room ID (if belongs to a direct room). |
| Date | The date and time when the last thread message was sent. |
| Number | The count of messages deleted in the thread. |
| Number | The count of messages in the thread. |
| MessageTypesValues (enum) | The message type. |
|
| The end-to-end encryption status of the message. |
| String | The acknowledgment status of an off-the-record message. |
| Array of objects | An array of URLs contained within the message. |
| Array of objects (deprecated) | An array of action links associated with the message. |
| FileProp (deprecated) | The file property associated with the message. |
| Object | Information about a file upload associated with the message. |
| Array of FileProp objects | An array of file properties associated with the message. |
| Array of MessageAttachment objects | An array of attachment objects, available only when the message has at least one attachment. |
| Object | Object containing reaction information associated with the message. |
| Boolean | Indicates whether the message is private. |
| Boolean (deprecated) | Indicates whether the message is sent by a bot. |
| Boolean | Indicates whether the message was sent by email. |
| Date | The date and time when a WebRTC call ended. |
| String | The role associated with the message. |
| String | A url to an image, that is accessible to anyone, to display as the avatar instead of the message user's account avatar |
| String | The emoji associated with the user who sent the message. |
| Array of Token objects | An array of tokens extracted from the message content. |
| String | The HTML representation of the message. |
| String (deprecated) | A deprecated field used for messages sent by visitors. |
| Object | Information about federation associated with the message. |
| Object (used for specific message types) | Additional data related to SLA (Service Level Agreements) change history messages. |
| Object (used for specific message types) | Additional data related to priority change history messages. |
The user presented on
u
andeditedBy
fields are a simplified version of the user information: (_id
: The user id,username
: The username, name: The name)The URL metadata contains several informational fields: (
url
: The URL itself (just as it appears on the message),meta
: URL metadata (varies accord to the URL),headers
: Some HTTP headers (varies accord to the URL),parsedUrl
: The parsed URL broken into its parts)
Message type
Some of the message types are listed below. A full list of the message-type property can be found here:
Rocket.Chat/MessageTypes.ts at 957c69d7ebdcf4dca02e7753bfd75086be11ca44 · RocketChat/Rocket.Chat
Type | Description |
---|---|
| Room name changed |
| User added by |
| User removed by |
| User left |
| User left team |
| User joined channel |
| User joined team |
| User joined conversation |
| Message removed |
| Added user to team |
| Removed user from team |
| User muted by |
Attachment object
The attachment object is fully described here
{
"messages": [
{
"_id": "message-id",
"rid": "room-id",
"msg": "Hello World!",
"ts": { "$date": 1480377601 },
"u": {
"_id": "user-id",
"username": "username"
},
"_updatedAt": { "$date": 1480377601 }
},
{
"_id": "message-id",
"rid": "room-id",
"msg": "Hello!",
"ts": { "$date": 1480377601 },
"u": {
"_id": "user-id",
"username": "username"
},
"_updatedAt": { "$date":1480377601 },
"editedAt": { "$date": 1480377601 },
"editedBy": {
"_id": "user-id",
"username": "username"
}
}
]
}