On this page

Manage channel updates

Update channel details and receive events whenever someone updates them.

Requires App Context

To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.

Update channel details

You can edit the metadata of an existing channel with Update() and UpdateChannel().

Both of them give the same output. The only difference is that you call a given method either on the Chat (UpdateChannel()) or the Channel (Update()) object. Depending on the object, these methods take a different set of input parameters - you either have to specify the channel ID you want to update or not because it's already known.

Method signature

These methods take the following parameters:

  • Update()

    1channel.Update(ChatChannelData updatedData)
    2
    3public class ChatChannelData
    4{
    5 public string Name { get; set; } = string.Empty;
    6 public string Description { get; set; } = string.Empty;
    7 public Dictionary<string, object> CustomData { get; set; } = new ();
    8 public string Status { get; set; } = string.Empty;
    9 public string Type { get; set; } = string.Empty;
    10}
  • UpdateChannel()

    1chat.UpdateChannel(
    2 string channelId,
    3 ChatChannelData updatedData
    4)
    5
    6public class ChatChannelData
    7{
    8 public string Name { get; set; } = string.Empty;
    9 public string Description { get; set; } = string.Empty;
    10 public Dictionary<string, object> CustomData { get; set; } = new ();
    11 public string Status { get; set; } = string.Empty;
    12 public string Type { get; set; } = string.Empty;
    13}

Input

ParameterRequired in Update()Required in UpdateChannel()Description
channelId
Type: string
Default:
n/a
No
Yes
Unique channel identifier.
 → Name
Type: string
Default:
n/a
No
No
Display name for the channel.
 → Description
Type: string
Default:
n/a
No
No
Additional details about the channel.
 → CustomData
Type: Dictionary<string, object>
Default:
n/a
No
No
JSON providing custom data about the channel. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn’t support filtering by custom properties.
 → Status
Type: string
Default:
n/a
No
No
Tag that categorizes a channel by its state, like archived.
 → Type
Type: string
Default:
n/a
No
No
Tag that categorizes a channel by its function, like offtopic.
API limits

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

Output

An awaitable Task<ChatOperationResult>.

Sample code

Update the description of the support channel.

  • Update()

    1
    
  • UpdateChannel()

    1
    

Get channel updates

You can receive updates when specific Channel object(s) are edited or removed on other clients using the following methods:

  • StreamUpdates() checks updates on a single Channel object and it's tied to an instance of the Channel class.
  • StreamUpdatesOn() checks updates on a Channel object list and it's tied to the Channel class.

Both methods accept a callback function as an argument. The Chat SDK invokes this callback whenever someone changes or removes channel metadata.

Underneath, these methods subscribe the current user to a channel and add an objects event listener to receive all objects events of type channel.

Change types

When streaming entity updates, you can use the ChatEntityChangeType enum to understand what kind of change occurred:

1public enum ChatEntityChangeType
2{
3 Updated, // Entity metadata or properties were modified
4 Deleted // Entity was removed
5}

This enum is used with the OnUpdate event and the StreamUpdatesOn() method (second overload) to provide the change type for each update.

Stream update behavior
  • StreamUpdates() enables listening for updates on a single channel. Use the OnChannelUpdate or OnUpdate events to handle changes.
  • StreamUpdatesOn() has two overloads:
    • StreamUpdatesOn(List<Channel>, Action<List<Channel>>) returns the complete list of channels you're monitoring each time any change occurs to any of them.
    • StreamUpdatesOn(List<Channel>, Action<Channel, ChatEntityChangeType>) returns only the specific channel that was updated along with the type of change (Updated or Deleted).
Method naming

Earlier versions used SetListeningForUpdates() to enable streaming. This method has been superseded by StreamUpdates(), though it remains available for backward compatibility.

Method signature

These methods take the following parameters:

  • StreamUpdates()

    1channel.StreamUpdates(bool stream)
  • OnChannelUpdate

    1// event on the Channel entity
    2public event Action<Channel> OnChannelUpdate;
    3// needs a corresponding event handler
    4void EventHandler(Channel channel)
  • OnUpdate

    1// event on the Channel entity
    2public event Action<Channel, ChatEntityChangeType> OnUpdate;
    3// needs a corresponding event handler
    4void EventHandler(Channel channel, ChatEntityChangeType changeType)
  • StreamUpdatesOn() (static) - returns all channels

    1Channel.StreamUpdatesOn(
    2 List<Channel> channels,
    3 Action<List<Channel>> listener
    4)
  • StreamUpdatesOn() (static) - returns individual channel with change type

    1Channel.StreamUpdatesOn(
    2 List<Channel> channels,
    3 Action<Channel, ChatEntityChangeType> listener
    4)

Input

ParameterRequired in StreamUpdates()Required in OnChannelUpdate / OnUpdateRequired in StreamUpdatesOn()Description
stream
Type: bool
Default:
n/a
Yes
n/a
n/a
Whether to start (true) or stop (false) listening to Channel object updates.
channels
Type: List<Channel>
Default:
n/a
No
No
Yes
List of Channel objects for which you want to get updates.
listener
Type: Action<List<Channel>>
Default:
n/a
No
No
Yes (first overload)
Callback that receives the complete list of all channels being monitored each time any change occurs.
listener
Type: Action<Channel, ChatEntityChangeType>
Default:
n/a
No
No
Yes (second overload)
Callback that receives the specific channel that was updated and the type of change.
changeType
Type: ChatEntityChangeType
Default:
n/a
n/a
No (only in OnUpdate)
No (only in second overload)
Enum indicating the type of change: Updated or Deleted.

Output

These methods don't return a value. Updates are delivered through event handlers or callback functions.

Sample code

  • StreamUpdates() and OnChannelUpdate

    Get updates on the support channel.

    1
    
  • StreamUpdatesOn() with individual channel updates

    Get updates on the support and incidentManagement channels. The callback receives each updated channel individually along with the change type.

    1
    
Last updated on