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

These methods let you receive updates when specific Channel objects are edited or removed on other clients:

  • SetListeningForUpdates() — listen for Channel object update information.
  • OnChannelUpdate — add a single event handler to a single Channel object update.
  • AddListenerToChannelsUpdate() — add a single event handler to each Channel object update from the provided list.

Method signature

These methods take the following parameters:

  • SerListeningForUpdates()

    1channel.SetListeningForUpdates(bool listen)
  • OnChannelUpdate

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

    1chat.AddListenerToChannelsUpdate(
    2 List<string> channelIds,
    3 Action<Channel> listener
    4).Wait();

Input

ParameterRequired in SetListeningForUpdatesRequired in OnChannelUpdateRequired in AddListenerToChannelsUpdate()Description
listen
Type: bool
Default:
n/a
Yes
n/a
n/a
Bool specifying whether to listen to Channel object updates.
channelIds
Type: List<string>
Default:
n/a
No
No
Yes
List of channels for which you want to get updates.
listener
Type: Action<Channel>
Default:
n/a
No
Yes
Yes
The definition of the custom behavior to be executed when detecting channel metadata changes.

Output

These methods don't return anything.

Sample code

  • SetListeningForUpdates() and OnChannelUpdate

    Get updates on the support channel.

    1
    
  • AddListenerToChannelsUpdate()

    Get updates on the support and incident-management channels.

    1
    
Last updated on