Load messages by timestamp or message ID
Using the getMessagesByTimestamp()
method or the getMessagesByMessageId()
method, you can retrieve a set number of previous and next messages on a specified timestamp or message ID in a channel.
The following code shows several types of parameters that you can configure to customize a message query by using MessageListParams
. Under the MessageListParams
object, you can assign values to properties such as prevResultSize
, messageTypeFilter
, and customTypesFilter
. To retrieve messages in a channel, you need to pass the MessageListParams
object as an argument to the parameter in the getMessagesByTimestamp()
method. The table below shows a list of parameters in MessageListParams
.
MessageListParams
Property name | Type | Description |
---|---|---|
prevResultSize | int | Specifies the number of messages to retrieve that were sent before the specified timestamp. |
nextResultSize | int | Specifies the number of messages to retrieve that were sent after the specified timestamp. |
isInclusive | boolean | Determines whether to include messages sent exactly on the specified timestamp or have the matching message ID. (Default: |
reverse | boolean | Determines whether to sort the retrieved messages in reverse order. If set to |
replyType | string | Specifies the type of message to include in the results. |
includeThreadInfo | boolean | Determines whether to include the thread information of the messages in the result. (Default: |
includeParentMessageInfo | boolean | Determines whether to include the information of the parent messages in the result. (Default: |
messageTypeFilter | Specifies the message type to filter the messages with the corresponding type. Acceptable values are | |
customTypesFilter | string | Filters messages to return only messages with the specified custom types. |
| boolean | (Deprecated) Determines whether replies are included in the results. |
| boolean | (Deprecated) Determines whether to include the parent message text in the results when the messages are replies in a thread. If the type of the parent message is |
By timestamp
To retrieve a set number of previous and next messages on a specified timestamp, use the getMessagesByTimestamp()
method and specify the TIMESTAMP
argument in Unix milliseconds
By Message ID
To retrieve a set number of previous and next messages of a specific message ID in a channel, use the getMessagesByMessageId()
method.