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.

Search open channels by name, URL, or custom types

You can search for specific open channels by adding a keyword to an OpenChannelListQuery instance, using nameKeyword and urlKeyword. In nameKeyword, you can add keywords to match channel names. In urlKeyword, you can add keywords to match channel URLs.

The code sample below shows the query instance which returns a list of open channels that match the specified nameKeyword in the channel names.

const params: OpenChannelListQueryParams = {
  nameKeyword: 'Sendbird',
};
const query: OpenChannelListQuery = sb.openChannel.createOpenChannelListQuery(params);

const channels: OpenChannel[] = await query.next();

The following shows the query instance which returns a list of open channels that match the specified urlKeyword in the channel URLs.

const params: OpenChannelListQueryParams = {
  urlKeyword: 'seminar',
};
const query: OpenChannelListQuery = sb.openChannel.createOpenChannelListQuery(params);

const channels: OpenChannel[] = await query.next();

By setting the customTypes values like the following, you can also search for open channels with any of the specified custom types.

const params: OpenChannelListQueryParams = {
  customTypes: ['movie', 'music'],
};
const query: OpenChannelListQuery = sb.openChannel.createOpenChannelListQuery(params);

const channels: OpenChannel[] = await query.next();