Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
Message
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Categorize messages by custom type

When sending a message, you can specify a custom message type to subclassify messages. This custom type takes on the form of String and can be useful in searching or filtering messages.

The data and customType properties of a message object allow you to append information to your messages. While both properties can be used flexibly, common examples for the customType include grouping message into categories such as Notes or Contacts.

To embed a custom type into your message, assign a value to the customType under the UserMessageCreateParams or FileMessageCreateParams object. Then, pass the specified object as an argument to the parameter in the sendUserMessage() or sendFileMessage() method.

To get a message's custom type, read the message.customType.

const params: UserMessageCreateParam = {
    message: TEXT_MESSAGE,
    customType: CUSTOM_TYPE,
};
channel.sendUserMessage(params)
    .onSucceeded((message: UserMessage) => {
        // ...
    })