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

Categorize channels by custom type

When creating an open channel or a group channel, you can additionally specify a custom channel type to subclassify channels. This custom type takes on the form of a string, and can be useful in searching or filtering channels.

The data and customType properties of a channel object allow you to append information to channels. While both properties can be used flexibly, common examples for using customType includes categorizing channels into "Personal" or "Work."

To get a channel's custom type, read openChannel.customType for open channels and groupChannel.customType for group channels.

Open channel

const params: OpenChannelCreateParams = {
    name: NAME,
    customType: CUSTOM_TYPE,
};
const channel: OpenChannel = await sb.openChannel.createChannel(params);

Group channel

const params: GroupChannelCreateParams = {
    invitedUserIds: ['James', 'Chris'],
    name: NAME,
    customType: CUSTOM_TYPE,
};
const channel: GroupChannel = await sb.groupChannel.createChannel(params);