For AI agents: this page in Markdown: https://www.pubnub.com/docs/chat/chat-sdk/learn/chat-entities/channel.md. Documentation index: https://www.pubnub.com/llms-full.txt.
Channel object
The Channel object represents a single chat room where users can send and receive messages.
Properties
The Channel object has the following properties:
1class Channel {
2 id: string,
3 name?: string,
4 custom?: ObjectCustom,
5 description?: string,
6 updated?: string,
7 status?: string,
8 type?: ChannelType
9}
name#- Display name or title of the channel.
custom#- Any custom properties or metadata associated with the channel in the form of a JSON. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn't support filtering by custom properties.
description#- Brief description or summary of the channel's purpose or content.
updated#- Timestamp for the last time the channel was updated or modified.
status#- Current status of the channel, like
online,offline, orarchived. type#- One of the available channel types:
direct(1:1)group(multiple people, restricted by invitation)public(open chat for a large audience, anyone can join it)unknownfor channels created using the JavaScript SDK instead of Chat SDK, whose type provided in channel metadata is different than the three default Chat SDK types.
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Methods
You can call the following methods on the Channel object.
Regular methods
createMessageDraft()delete()deleteFile()emitCustomEvent()fetchReadReceipts()forwardMessage()getFiles()getHistory()getMember()getMembers()getMessage()getMessageReportsHistorygetPinnedMessage()getUserRestrictions()getUsersRestrictions()getUserSuggestions()hasMember()invite()inviteMultiple()isPresent()join()leave()pinMessage()registerForPush()sendText()setRestrictions()startTyping()stopTyping()update()unpinMessage()unregisterFromPush()whoIsPresent()
Event listeners
onCustomEvent()onDeleted()onMessageReceived()onMessageReported()onPresenceChanged()onReadReceiptReceived()onTypingChanged()onUpdated()
Use case
For example, you can use the Channel object methods to:
- Let users send messages.
- Create and manage a 1:1, group, or public channel (chat).
- Invite others to join the channel.
- Configure a typing indicator to track when someone in the room is writing a message.
- Register the channel for mobile push notifications, not to miss a single message.