On this page

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:

1public class Channel : UniqueChatEntity {
2 public string Id { get; protected set; }
3 public string Name { get; }
4 public string Description { get; }
5 public Dictionary<string, object> CustomData { get; }
6 public string Updated { get; }
7 public string Status { get; }
8 public string Type { get; }
9}
ParameterDescription
Id
Type: string
Unique identifier for the channel. Verify the channel ID with our validator.
Name
Type: string
Display name or title of the channel.
Description
Type: string
Brief description or summary of the channel's purpose or content.
CustomData
Type: Dictionary<string, object>
Custom data 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.
Updated
Type: string
Timestamp indicating when the channel was last updated or modified.
Status
Type: string
Current status of the channel, such as online, offline, or archived.
Type
Type: string
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)
API limits

To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.

Events​

The Channel object has the following events:

1// Event triggered when a message is received on a channel.
2// Call Connect(true) to enable this callback.
3public event Action<Message> OnMessageReceived;
4// Event triggered when a channel is updated.
5// Call StreamUpdates(true) to enable this callback.
6public event Action<Channel> OnUpdated;
7// Event triggered when a channel is hard-deleted from App Context.
8// Call StreamUpdates(true) to enable this callback.
9public event Action OnDeleted;
10// Event triggered when a presence state changes on a channel.
11// Call StreamPresence(true) to enable this callback.
12public event Action<List<string>> OnPresenceUpdate;
13// Event triggered when typing is detected on a channel.
14// Call StreamTyping(true) to enable this callback.
15public event Action<List<string>> OnUsersTyping;
show all 24 lines

Example​

An event that is triggered when a new message is received on a channel.

1

Methods​

You can call the following methods on the Channel object.

Click on each method for more details.

Standard methods​

Streaming methods​

These methods register or unregister real-time event subscriptions. Each streaming method activates one or more of the events listed in the Events section above.

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.
  • Check if a user is a member of the channel.
  • Configure a typing indicator to track when someone in the room is writing a message.