---
source_url: https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/create
title: Create channels
updated_at: 2026-05-20T11:04:56.080Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Create channels

:::tip Channel naming
Before creating channels, take the time to carefully plan your [naming strategy](https://www.pubnub.com/docs/general/channels/channel-naming). Stick to consistent naming conventions and structure your channels thoughtfully. This preparation helps you avoid increased complexity, performance bottlenecks, and scalability issues, ensuring your app remains manageable and efficient as it grows.
:::

Create channels ([Channel](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel) objects) of one of these types:

* [Direct (1:1)](#create-direct-channel)
* [Group](#create-group-channel)
* [Public](#create-public-channel)

##### Usage in Blueprints and C++

You can use PubNub's functionality via Blueprints or directly in C++ code.

* In Blueprints, you can access PubNub from any Widget or Actor. Start by [initializing chat](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub-chat) using `InitChat` on `UPubnubChatSubsystem`. Afterwards, you can use the returned `UPubnubChat` object reference to call all Chat SDK functions.

:::warning Blueprint functions
The Blueprints provided in the documentation show how you can structure your application and may contain utility methods and elements like buttons that are not part of the Unreal Chat SDK and are meant to serve as guidance.
:::

* In C++, you can use UPubnubChatSubsystem as any other Game Instance Subsystem. #include "Kismet/GameplayStatics.h" #include "Engine/GameInstance.h" #include "PubnubChatSubsystem.h" // ACTION REQUIRED: Replace ASample_ChatSubsystem with name of your Actor class void ASample_ChatSubsystem::InitChatSample() { // Get PubnubChatSubsystem from GameInstance UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this); UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>(); // Initialize Chat - InitChat may fail under some conditions so make sure to check the Result for errors before using the Chat FPubnubChatInitChatResult InitChatResult = PubnubChatSubsystem->InitChat(TEXT("demo"), TEXT("demo"), TEXT("Player_001")); UPubnubChat* PubnubChat = InitChatResult.Chat; } Chat now allows you to call all Chat SDK functions, for example, Chat->GetChannel("my_channel").

:::note Requires App Context
To store data about channels, you must [enable App Context](https://youtu.be/9UEoSlngpYI) for your app's keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

:::warning No support for channel groups
Chat SDKs don't support channel groups. We recommend using a [Core SDK](https://www.pubnub.com/docs/sdks) to manage [channel groups](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups).
:::

## Create direct channel

Direct channels enable private 1:1 conversations. Use cases include personal conversations and professional collaboration.

`CreateDirectConversation()` performs these actions:

1. Creates a channel with the `direct` type
2. Sets [channel membership](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership) for the channel owner
3. [Invites](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/invite#invite-one-user) the other user and creates a membership with a `"pending"` status (generates an [invite event](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/custom-events#events-for-channel-initations))

If a conversation between the two users already exists, the method returns that existing channel.

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

#### C++ / Input parameters

```cpp
Chat->CreateDirectConversation(
    UPubnubChatUser* User, 
    FString ChannelID, 
    FPubnubChatChannelData ChannelData, 
    FPubnubChatMembershipData HostMembershipData = FPubnubChatMembershipData()
);
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| User | UPubnubChatUser* | Yes |  | User that you invite to join a channel. |
| ChannelID | FString | Optional |  | ID of the direct channel. The channel ID is created automatically by a hashing function that takes the string of two user names joined by `&`, computes a numeric value based on the characters in that string, and adds the `direct` prefix in front. For example, `direct.1234567890`. You can override this default value by providing your own ID. |
| ChannelData | FPubnubChatChannelData | Optional |  | Information about the channel. This function overwrites the value of the `Type` field and always sets it to `"direct"`. |
| HostMembershipData | FPubnubChatMembershipData | Optional |  | The object containing all information about the user-channel [membership](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership). For more information, refer to [FPubnubChatMembershipData](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership#fpubnubchatmembershipdata). |

#### FPubnubChatChannelData

| Parameter | Description |
| --- | --- |
| `ChannelName`Type: `FString`Default: n/a | Display name for the channel (must not be empty or consist only of whitespace characters). |
| `Description`Type: `FString`Default: n/a | Detailed description of the channel's purpose or topic. |
| `Custom`Type: `FString`Default: n/a | JSON providing custom data about the channel. Values must be scalar only; arrays or objects are not supported. [Filtering App Context data](https://www.pubnub.com/docs/general/metadata/filtering) through the `custom` property is not recommended in SDKs. |
| `Status`Type: `FString`Default: n/a | Tag that lets you categorize your app channels by their current state. The tag choice is entirely up to you and depends on your use case. Maximum length is 50 characters. |
| `Type`Type: `FString`Default: n/a | Tag that lets you categorize your app channels by their functional roles. The tag choice is entirely up to you and depends on your use case. Maximum length is 50 characters. |

#### Blueprint

:::tip API limits
To learn about the maximum length of parameters used to set channel metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-channel-metadata).
:::

#### Output

| Parameter | Description |
| --- | --- |
| `FPubnubChatCreateDirectConversationResult`Type: `struct` | Returned object containing these fields: `Result`, `Channel`, `HostMembership`, and `InviteeMembership`. |
| → `Result`Type: `FPubnubChatOperationResult` | Operation result with `Error` (bool) and `ErrorMessage` (FString). |
| → `Channel`Type: [UPubnubChatChannel*](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel) | Returned object containing the created channel metadata. |
| → `HostMembership`Type: [UPubnubChatMembership*](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership) | Returned object containing the host (channel owner) membership. |
| → `InviteeMembership`Type: `UPubnubChatMembership*` | Returned object containing the invited user's membership. |

### Sample code

:::tip Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with `ACTION REQUIRED` before running the code. Use it as a reference when working with other examples in this document.
:::

Create a direct conversation with another user asynchronously.

###### Actor.h

```cpp
// blueprint.y_mgu55n
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Channel")
void CreateDirectConversationSample();

UFUNCTION()
void OnCreateDirectConversationResponse(const FPubnubChatCreateDirectConversationResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::CreateDirectConversationSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat
	
	// OtherUser: the user to start a direct chat with (e.g. from GetUser)
	UPubnubChatUser* OtherUser = nullptr;

	FOnPubnubChatCreateDirectConversationResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnCreateDirectConversationResponse);
	Chat->CreateDirectConversationAsync(OtherUser, Callback);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnCreateDirectConversationResponse(const FPubnubChatCreateDirectConversationResult& Result)
{
	if (Result.Result.Error) { return; }
	UPubnubChatChannel* Channel = Result.Channel;
}
```

## Create group channel

Group channels enable multi-user conversations for team collaboration and community building. Access requires an invitation.

`CreateGroupConversation()` performs these actions:

1. Creates a channel with the `group` type
2. Sets channel membership for the channel owner
3. [Invites](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/invite#invite-multiple-users) other users to join and creates memberships with a `"pending"` status

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

#### C++ / Input parameters

```cpp
Chat->CreateGroupConversation(
    TArray<UPubnubChatUser*> Users, 
    FString ChannelID, 
    FPubnubChatChannelData ChannelData, 
    FPubnubChatMembershipData HostMembershipData = FPubnubChatMembershipData()
);
```

| Parameter | Description |
| --- | --- |
| `Users` *Type: `TArray<UPubnubChatUser*>` | Array of users that you invite to join a channel. You can invite a maximum number of 100 users at once. |
| `ChannelID`Type: `FString` | ID of the group channel. |
| `ChannelData`Type: [FPubnubChatChannelData](#fpubnubchatchanneldata) | Information about the channel. If you don't provide the name, the channel will get the same name as [id](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel). This function overwrites the value of the `Type` field and always sets it to `"group"`. |
| `HostMembershipData`Type: `FPubnubChatMembershipData` | The object containing all information about the user-channel [membership](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership). For more information, refer to [FPubnubChatMembershipData](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership#fpubnubchatmembershipdata). |

#### Blueprint

#### Output

| Parameter | Description |
| --- | --- |
| `FPubnubChatCreateGroupConversationResult`Type: `struct` | Returned object containing these fields: `Result`, `Channel`, `HostMembership`, and `InviteesMemberships`. |
| → `Result`Type: `FPubnubChatOperationResult` | Operation result with `Error` (bool) and `ErrorMessage` (FString). |
| → `Channel`Type: [UPubnubChatChannel*](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel) | Returned object containing the created channel metadata. |
| → `HostMembership`Type: [UPubnubChatMembership*](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership) | Returned object containing the host (channel owner) membership. |
| → `InviteesMemberships`Type: `TArray<UPubnubChatMembership*>` | Returned object containing the invited users' memberships. |

### Sample code

:::tip Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with `ACTION REQUIRED` before running the code. Use it as a reference when working with other examples in this document.
:::

Create a group conversation and invite users to join asynchronously.

###### Actor.h

```cpp
// blueprint.cz93qx3q
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Channel")
void CreateGroupConversationSample();

UFUNCTION()
void OnCreateGroupConversationResponse(const FPubnubChatCreateGroupConversationResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::CreateGroupConversationSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat
	
	// UsersToInvite: populate with users to invite (e.g. from GetUser/GetUsers); at least one required
	TArray<UPubnubChatUser*> UsersToInvite;

	FPubnubChatChannelData ChannelData;
	ChannelData.ChannelName = TEXT("Squad Chat");

	FOnPubnubChatCreateGroupConversationResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnCreateGroupConversationResponse);
	Chat->CreateGroupConversationAsync(UsersToInvite, Callback, TEXT(""), ChannelData);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnCreateGroupConversationResponse(const FPubnubChatCreateGroupConversationResult& Result)
{
	if (Result.Result.Error) { return; }
	UPubnubChatChannel* Channel = Result.Channel;
}
```

### Other examples

#### Create group conversation with custom data

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Channel")
void CreateGroupConversationExampleSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::CreateGroupConversationExampleSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Create user objects for the agents to invite
	FPubnubChatUserData UserData_007;
	UserData_007.UserName = "Agent 007";
	FPubnubChatUserResult UserResult_007 = Chat->CreateUser("agent-007", UserData_007);
	if (UserResult_007.Result.Error) { return; }

	FPubnubChatUserData UserData_008;
	UserData_008.UserName = "Agent 008";
	FPubnubChatUserResult UserResult_008 = Chat->CreateUser("agent-008", UserData_008);
	if (UserResult_008.Result.Error) { return; }

	// Define the conversation/channel ID and metadata
	FString ChannelID = "group.agent-007&agent-008&my_user";

	FPubnubChatChannelData ChannelData;
	ChannelData.ChannelName = "Weekly Sync on Customer XYZ";
	ChannelData.Description = "Weekly discussion regarding customer XYZ";
	ChannelData.Custom = "{\"topic\": \"customer XYZ\", \"frequency\": \"weekly\"}";
	ChannelData.Status = "active";
	ChannelData.Type = "group";

	FPubnubChatMembershipData MembershipData;
	MembershipData.Custom = "{\"role\": \"premium-support\"}";
	MembershipData.Status = "active";
	MembershipData.Type = "player";

	// Create the group conversation with invited users and custom membership data
	TArray<UPubnubChatUser*> Users = { UserResult_007.User, UserResult_008.User };
	FPubnubChatCreateGroupConversationResult CreatedResult = Chat->CreateGroupConversation(Users, ChannelID, ChannelData, MembershipData);
}
```

## Create public channel

Public channels are open to anyone without invitation. Use cases include Q&A forums, knowledge sharing, and live event chat.

:::warning Supported features
Public channels do not support [typing indicators](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/typing-indicator) or [read receipts](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/messages/read-receipts). These features are impractical for large audiences.
:::

`CreatePublicConversation()` creates a channel with the `public` type and the specified metadata.

:::note Receive messages
Call [Connect()](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/watch) to start receiving messages on the channel.
:::

### Method signature

#### C++ / Input parameters

```cpp
Chat->CreatePublicConversation(
    FString ChannelID, 
    FPubnubChatChannelData ChannelData
);
```

| Parameter | Description |
| --- | --- |
| `ChannelID`Type: `FString` | ID of the public channel. |
| `ChannelData`Type: [FPubnubChatChannelData](#fpubnubchatchanneldata) | Information about the channel. If you don't provide the name, the channel will get the same name as [id](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel). This function overwrites the value of the `Type` field and always sets it to `"public"`. |

#### Blueprint

:::tip API limits
To learn about the maximum length of parameters used to set channel metadata, refer to [REST API docs](https://www.pubnub.com/docs/sdks/rest-api/set-channel-metadata).
:::

#### Output

| Parameter | Description |
| --- | --- |
| `FPubnubChatChannelResult`Type: `struct` | Returned object containing `Result` (`FPubnubChatOperationResult`) and `Channel` (`UPubnubChatChannel*`). |

### Sample code

:::tip Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with `ACTION REQUIRED` before running the code. Use it as a reference when working with other examples in this document.
:::

Create a public channel asynchronously.

###### Actor.h

```cpp
// blueprint.ex6bqzof
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Channel")
void CreatePublicConversationSample();

UFUNCTION()
void OnCreatePublicConversationResponse(const FPubnubChatChannelResult& Result);
```

###### Actor.cpp

```cpp
#include "PubnubChatChannel.h"

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::CreatePublicConversationSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Create a public channel (e.g. lobby or global chat); optional metadata
	FPubnubChatChannelData ChannelData;
	ChannelData.ChannelName = TEXT("Game Lobby");
	ChannelData.Description = TEXT("Main lobby channel");

	FOnPubnubChatChannelResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnCreatePublicConversationResponse);
	Chat->CreatePublicConversationAsync(TEXT("Lobby_001"), Callback, ChannelData);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnCreatePublicConversationResponse(const FPubnubChatChannelResult& Result)
{
	if (Result.Result.Error) { return; }
	UPubnubChatChannel* Channel = Result.Channel;
}
```

### Other examples

#### Create public conversation with custom data

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Channel")
void CreatePublicConversationExampleSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::CreatePublicConversationExampleSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Define the conversation/channel ID
	FString ChannelID = "ask-support";

	// Define the channel data
	FPubnubChatChannelData ChannelData;
	ChannelData.ChannelName = "ask-support";
	ChannelData.Description = "Space dedicated to answering all support-related questions";

	// Create the public conversation
	FPubnubChatChannelResult ChannelResult = Chat->CreatePublicConversation(ChannelID, ChannelData);
	if (ChannelResult.Result.Error) { return; }
	UPubnubChatChannel* Channel = ChannelResult.Channel;
}
```