/ SDKs / .NET
SDKs
Chat SDKs .NET v4
Chat SDKs .NET
Chat SDKs
.NET
Version 4

Create a channel

Copy link

Two basic types of channels you can create with Sendbird Chat SDK are open channels and group channels.

An open channel is ideal for use cases that don't require a permanent membership in the channel, such as short-lived live events and news-feed style messaging to a large audience. On the other hand, a group channel is suitable for closer interactions among a limited number of users. To learn more about the different use cases and characteristics of open and group channels, see the channel overview page.

When creating a channel, you can append additional information like cover image, description, and URL by passing several arguments to the corresponding parameters. The channel URL can only contain numbers, letters, underscores, or hyphens, and the URL's length must be between 4 and 100 characters. If you don't specify the Url property, a URL is automatically generated.

If you want to create and continue to use a single group channel for a 1-to-1 chat, set the IsDistinct property of the channel to true. If the IsDistinct property is set to false, multiple 1-to-1 channels with their own chat history and data may be created for the same two users even if a channel already exists between them.

Note: By default, the Allow creating open channels and Allow creating group channels options are turned on, which means that any user can create open and group channels with Sendbird Chat SDK. This may grant access to unwanted data or operations, leading to potential security concerns. To manage your access control settings, you can turn on or off each option in Settings > Application > Security > Access control list on Sendbird Dashboard.


Open channel

Copy link

An open channel is ideal for use cases that require a small and static number of channels. To create an open channel from Sendbird Dashboard, do the following.

  1. On Sendbird Dashboard, go to Chat > Open channels, and then click Create channel at the top-right corner.
  2. In the dialog box that appears, specify the name, unique URL, cover image, and custom type of a channel.

Alternatively, you can create a channel on demand or dynamically through the Chat SDK or the Chat Platform API. Use the following code to create a channel through the Chat SDK.

SbOpenChannelCreateParams openChannelCreateParams = new SbOpenChannelCreateParams();
openChannelCreateParams.Data = DATA;
openChannelCreateParams.CustomType = NAME;
openChannelCreateParams.OperatorUserIds = new List<string> { OPERATOR_USER_ID };

SendbirdChat.OpenChannel.CreateChannel(openChannelCreateParams, (inChannel, inError) =>
{
    if (inError != null)
        return; //Handle error.
});

Or you can create an open channel by configuring an SbOpenChannelCreateParams object like the following.

SbOpenChannelCreateParams openChannelCreateParams = new SbOpenChannelCreateParams();
openChannelCreateParams.ChannelUrl = CHANNEL_URL;
openChannelCreateParams.Data = DATA;
openChannelCreateParams.CustomType = NAME;
openChannelCreateParams.CustomType = CUSTOM_TYPE;
openChannelCreateParams.OperatorUserIds = new List { OPERATOR_USER_ID };
SendbirdChat.OpenChannel.CreateChannel(openChannelCreateParams, (inChannel, inError) =>
    if (inError != null)
        return; //Handle error.
});

SbOpenChannelCreateParams

Copy link
Property nameTypeDescription

name

string

Specifies the channel topic, or the name of the channel.

channelUrl

string

Specifies a unique channel URL given when a new open channel is created.

data

string

Specifies additional channel information such as a long description of the channel or JSON formatted string.

operatorUserIds

List<string>

Specifies an array of one or more users to register as operators of the channel. Operators can delete any messages, and also view all messages in the channel without any filtering or throttling.

customType

string

Specifies the custom channel type which is used for channel grouping.

Note: See categorize channels by custom type for more information on cover images and custom types.


Group channel

Copy link

A user can create a group channel by inviting other users in their client app. At the implementation level, you need to create a SbGroupChannelCreateParams object with a list of user IDs to invite. In the params, you can also specify a user ID to designate an operator in the channel. Then, run code that passes the user ID list as an argument to a parameter in the CreateChannel() method.

Before running the code that creates a group channel for a typical 1-to-1 chat, you should make sure that you set the value of the IsDistinct property to true. If the value of the IsDistinct property is set to false, a new channel is created with the same two users even if there is already an existing channel between them. In this case, multiple 1-to-1 channels between the same two users can exist, each with its own chat history and data.

However, if you plan to create a Supergroup channel, the value of the IsDistinct property should be set to false.

SbGroupChannelCreateParams groupChannelCreateParams = new SbGroupChannelCreateParams();
groupChannelCreateParams.UserIds = new List { USER_ID };
groupChannelCreateParams.OperatorUserIds = new List { OPERATOR_USER_ID };
SendbirdChat.GroupChannel.CreateChannel(groupChannelCreateParams, (inChannel, inError) =>
{
if (inError != null)
return; 
// Handle error.
});

SbGroupChannelCreateParams

Copy link
Property nameTypeDescription

inUserIds

List<string>

A list of user IDs to include as channel members.

operatorUserIds

List<string>

A list of user IDs to include as channel operators.


Supergroup channel

Copy link

Creating a Supergroup channel follows the exact same process of creating a group channel with the exception of the IsSuper property. The SbGroupChannelCreateParams class has the IsSuper property that determines whether a newly created channel is a Supergroup channel or a regular group channel. Set the value of this property to true to create a new Supergroup channel.

Because the distinct option isn't available for Supergroup channels, the IsDistinct property is set to false by default when creating a Supergroup channel.

SbGroupChannelCreateParams groupChannelCreateParams = new SbGroupChannelCreateParams();
groupChannelCreateParams.UserIds = new List { USER_ID };
groupChannelCreateParams.OperatorUserIds = new List { OPERATOR_USER_ID };
groupChannelCreateParams.IsSuper = true;
SendbirdChat.GroupChannel.CreateChannel(groupChannelCreateParams, (inChannel, inError) =>
{
if (inError != null)
return; 
// Handle error.
});