Create channels

Create channels (Channel objects) of one of these types:

icon

Usage in Blueprints and C++


Requires App Context

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

Create direct channel

Direct channels enable private conversations between two users, letting one person initiate the chat and send an invitation to another person for:

  • Personal conversations - you can engage in private conversations with friends, family, or colleagues, sharing personal updates, discussing sensitive matters, or planning social events.

  • Professional collaboration - you can use 1:1 chat to have focused discussions, exchange confidential information, provide feedback, or coordinate tasks with colleagues and business partners.

CreateDirectConversation() is a method that:

  1. Creates a direct (one-on-one) channel type.
  2. Sets channel membership for the channel owner (so that they can join the channel).
  3. Invites the other user to join the channel. As a result, an event of the invite type gets created. You can listen to these events in your chat app and notify the invited users.

If you call this method to create a channel for users that already had a conversation which was not deleted, this conversation is retrieved.

Receive messages

Note that you still have to call the Connect() method to subscribe to message event listeners and start receiving messages on the channel.

Method signature

API limits

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

Output

ParameterTypeDescription
FPubnubCreatedChannelWrapperFPubnubCreatedChannelWrapperReturned object containing these fields: CreatedChannel, HostMembership, and InviteesMemberships.
 → CreatedChannelUPubnubChannel*Returned object containing the updated channel metadata.
 → HostMembershipUPubnubMembership*Returned object containing the updated host (channel owner) metadata.
 → InviteesMembershipsTArray<UPubnubMembership*>Returned object containing the updated data of the invited users.

Basic usage

Invite agent-007 to a 1:1 conversation to talk about customer XYZ.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");

// First, create a user object for agent-007
FString UserID = "agent-007";
FPubnubChatUserData UserData;
UserData.UserName = "Agent 007";

// Create the user
UPubnubUser* InvitedUser = Chat->CreateUser(UserID, UserData);
show all 32 lines

Create group channel

Group channels enable communication among multiple users, promoting collaboration and teamwork. A user can initiate a group chat and invite others to be channel members for:

  • Team collaboration - members of a project team can use group chat to share updates, exchange ideas, ask questions, and provide status updates. This boosts real-time collaboration and productivity and ensures everyone stays on the same page.

  • Community building - group chat allows like-minded individuals to connect, discuss shared interests, organize events, and build strong communities around specific topics, hobbies, or professional fields.

Such a chat type is restricted by invitation, and you can access it only when invited.

CreateGroupConversation() is a method that:

  1. Creates a group channel type.
  2. Sets channel membership for the channel owner (so that they can join the channel).
  3. Invites other users to join the channel.
Receive messages

Note that you still have to call the Connect() method to subscribe to message event listeners and start receiving messages on the channel.

Method signature

Output

ParameterTypeDescription
FPubnubCreatedChannelWrapperFPubnubCreatedChannelWrapperReturned object containing these fields: CreatedChannel, HostMembership, and InviteesMemberships.
 → CreatedChannelUPubnubChannel*Returned object containing the updated channel metadata.
 → HostMembershipUPubnubMembership*Returned object containing the updated host (channel owner) metadata.
 → InviteesMembershipsTArray<UPubnubMembership*>Returned object containing the updated data of the invited users.

Basic usage

Create a group conversation and invite agent-007 and agent-008 to have weekly syncs on customer XYZ.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

// Get the GameInstance and Chat subsystem
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");

// Create user objects for agent-007 and agent-008
FString UserID_007 = "agent-007";
FPubnubChatUserData UserData_007;
UserData_007.UserName = "Agent 007";
UPubnubUser* InvitedUser_007 = Chat->CreateUser(UserID_007, UserData_007);

FString UserID_008 = "agent-008";
show all 35 lines

Create public channel

Supported features

The public channel type comes with certain limitations in place - you'll get errors when trying to implement such Unreal Chat SDK features as typing indicator, invites, or read receipts in public channels since these features are neither useful nor practical for large audiences.

Public channels let users engage in open conversations with many people. Unlike group chats, anyone can join public channels. Example use cases include:

  • Knowledge sharing and Q&A - public chats provide a platform for users to seek advice, share knowledge, and participate in discussions related to specific topics, fostering a community-driven environment.

  • Events and webinars - organizations can host public chats during live events, webinars, or panel discussions, allowing attendees to interact with presenters, ask questions, and share insights in real time.

CreatePublicConversation() is a method that creates such a public channel type with specified metadata.

Receive messages

Note that you still have to call the Connect() method to subscribe to message event listeners and start receiving messages on the channel.

Method signature

API limits

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

Output

ParameterTypeDescription
ChannelUPubnubChannel*Object returning the created channel metadata.

Basic usage

Create a public ask-support channel.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");

// 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";
show all 18 lines
Last updated on