/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Retrieve a message

Copy link

You can retrieve a specific message in an open or group channel by creating and passing the MessageRetrievalParams object to the getMessage() method as a parameter.

JavaScriptTypeScript
const params = {
    messageId: MESSAGE_ID,
    channelType: CHANNEL_TYPE,
    channelUrl: CHANNEL_URL,
};
// ...
const message = await sb.message.getMessage(params);

List of parameters

Copy link
Parameter nameTypeDescription

messageId

long

Specifies the unique ID of the message.

channelType

string

Specifies the type of the channel.

channelUrl

string

Specifies the URL of the channel.


Retrieve the last message of a group channel

Copy link

You can retrieve and view the last message sent in a group channel.

JavaScriptTypeScript
const lastMessage = groupChannel.lastMessage;

Depending on the type of message, cast BaseMessage to UserMessage, FileMessage, or AdminMessage to access the properties you need.