Message
    • Dark
      Light
    • PDF

    Message

    • Dark
      Light
    • PDF

    Article summary

    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.

    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

    _id

    String

    The unique identifier for the message.

    rid

    String

    The unique ID for the room. This will identify the room that the message belongs to. Example: 'GENERAL'

    msg

    String

    The content of the message.

    tmid

    String

    The ID of the thread to which the message belongs.

    tshow

    Boolean

    Indicates whether the thread should be shown.

    ts

    Date

    A timestamp of when the message was created. (The date of creation on client)

    mentions

    Array of objects

    An array of user mentions within the message. Identifies (type:"type of the mention; either user or tea", _id: ID of the user that is mentioned, username: username of the user that is mentioned", name: name of the user that is mentioned).

    groupable

    Boolean

    Boolean that states whether or not this message should be grouped together with other messages from the same user.

    channels

    Array of objects

    An array of channels to which the message belongs.

    u

    Object

    The user who sent the message (either the _id or username or name).

    blocks

    MessageSurfaceLayout (enum)

    If it is a UIkit message, then the UIkit blocks components.

    alias

    String

    An alias for the message sender.

    md

    Array of object

    The message's content in a markdown format.

    _hidden

    Boolean

    Indicates whether the message is hidden.

    imported

    Boolean

    Indicates whether the message is imported.

    replies

    Array of strings

    An array of user IDs representing the message replies.

    location

    Object

    The geographic location associated with the message.

    starred

    Array of objects

    A list of users that have the message starred (list of user IDs` (_id)

    pinned

    Boolean

    Indicates whether the message is pinned.

    pinnedAt

    Date

    The date and time when the message was pinned.

    pinnedBy

    Object

    Information about the user who pinned the message.

    unread

    Boolean

    Indicates whether the message is unread.

    temp

    Boolean

    Indicates whether the message is temporary.

    drid

    String

    The direct room ID (if belongs to a direct room).

    tlm

    Date

    The date and time when the last thread message was sent.

    dcount

    Number

    The count of messages deleted in the thread.

    tcount

    Number

    The count of messages in the thread.

    t

    MessageTypesValues (enum)

    The message type.

    e2e

    pending or done (enum)

    The end-to-end encryption status of the message.

    otrAck

    String

    The acknowledgment status of an off-the-record message.

    urls

    Array of objects

    An array of URLs contained within the message.

    actionLinks

    Array of objects (deprecated)

    An array of action links associated with the message.

    file

    FileProp (deprecated)

    The file property associated with the message.

    fileUpload

    Object

    Information about a file upload associated with the message.

    files

    Array of FileProp objects

    An array of file properties associated with the message.

    attachments

    Array of MessageAttachment objects

    An array of attachment objects, available only when the message has at least one attachment.

    reactions

    Object

    Object containing reaction information associated with the message.

    private

    Boolean

    Indicates whether the message is private.

    bot

    Boolean (deprecated)

    Indicates whether the message is sent by a bot.

    sentByEmail

    Boolean

    Indicates whether the message was sent by email.

    webRtcCallEndTs

    Date

    The date and time when a WebRTC call ended.

    role

    String

    The role associated with the message.

    avatar

    String

    A url to an image, that is accessible to anyone, to display as the avatar instead of the message user's account avatar

    emoji

    String

    The emoji associated with the user who sent the message.

    tokens

    Array of Token objects

    An array of tokens extracted from the message content.

    html

    String

    The HTML representation of the message.

    token

    String (deprecated)

    A deprecated field used for messages sent by visitors.

    federation

    Object

    Information about federation associated with the message.

    slaData

    Object (used for specific message types)

    Additional data related to SLA (Service Level Agreements) change history messages.

    priorityData

    Object (used for specific message types)

    Additional data related to priority change history messages.

    • The user presented on u and editedBy 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:

    Type

    Description

    r

    Room name changed

    au

    User added by

    ru

    User removed by

    ul

    User left

    ult

    User left team

    uj

    User joined channel

    ujt

    User joined team

    ut

    User joined conversation

    rm

    Message removed

    added-user-to-team

    Added user to team

    removed-user-from-team

    Removed user from team

    user-muted

    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"
                }
            }
        ]
    }


    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence