---
source_url: https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/invite
title: Invite users to channels
updated_at: 2026-06-19T11:35:26.213Z
---

> 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


# Invite users to channels

:::note Requires App Context
Enable [App Context](https://youtu.be/9UEoSlngpYI) for your keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

Invite users to private or group conversations, creating their channel [membership](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/membership). Invitations trigger an [invite event](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/custom-events#events-for-channel-initations) that you can [listen to](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/channels/invite#listen-to-invite-events) and notify invited users.

##### 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 Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
* Asynchronous methods (Async suffix) return void and take an optional delegate parameter that fires when the operation completes. 1Channel->InviteAsync(User, OnInviteResponseDelegate); You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubChatInviteResponseNative).
* Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly. 1FPubnubChatInviteResult Result = Channel->Invite(User);
:::

To send notifications on invitations, implement custom logic to:

* [Create and send custom events](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/custom-events#create-and-send-events) when invitations are sent
* Let invited users [receive these events](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/custom-events#receive-current-events)

## Invite one user

Request a user to join a channel with `Invite()`.

### Method signature

```cpp
Channel->Invite(UPubnubChatUser* User);
```

#### Input

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| User | UPubnubChatUser* | Yes |  | User that you want to invite to a 1:1 channel. |

#### Output

| Type | Description |
| --- | --- |
| `FPubnubChatInviteResult` | Returned object containing `Result` (`FPubnubChatOperationResult`) and `Membership` (`UPubnubChatMembership*`). |

### 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.
:::

Invite a user to a channel asynchronously.

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatChannel")
void InviteSample();

UFUNCTION()
void OnInviteResponse(const FPubnubChatInviteResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::InviteSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// User to invite (e.g. from GetUser or user lookup)
	UPubnubChatUser* User = nullptr;

	// Callback for when the invite completes (returns created/existing membership)
	FOnPubnubChatInviteResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatChannel::OnInviteResponse);
	Channel->InviteAsync(User, Callback);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnInviteResponse(const FPubnubChatInviteResult& Result)
{
	if (Result.Result.Error) { return; }
	UPubnubChatMembership* Membership = Result.Membership;
}
```

## Invite multiple users

Request multiple users to join a channel with `InviteMultiple()`. Maximum 100 users per call.

### Method signature

```cpp
Channel->InviteMultiple(TArray<UPubnubChatUser*> Users);
```

#### Input

| Parameter | Description |
| --- | --- |
| `Users` *Type: `TArray<UPubnubChatUser*>`Default: n/a | Array of users you want to invite to the group channel. You can invite up to 100 users in one call. |

#### Output

| Type | Description |
| --- | --- |
| `FPubnubChatInviteMultipleResult` | Returned object containing `Result` (`FPubnubChatOperationResult`) and `Memberships` (`TArray<UPubnubChatMembership*>`). |

### Sample code

Invite `support-agent-15` and `support-agent-16` to join the `high-prio-incidents` channel.

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::InviteMultipleSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// Users to invite (e.g. from GetUser or user lookup; at least one valid required)
	TArray<UPubnubChatUser*> Users;

	// Callback for when the operation completes (returns created memberships)
	FOnPubnubChatInviteMultipleResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatChannel::OnInviteMultipleResponse);
	Channel->InviteMultipleAsync(Users, Callback);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnInviteMultipleResponse(const FPubnubChatInviteMultipleResult& Result)
{
	if (Result.Result.Error) { return; }
	TArray<UPubnubChatMembership*> Memberships = Result.Memberships;
}
```

## Get invitees

Get invitees (members with pending status) for this channel with `GetInvitees()`.

### Method signature

```cpp
Channel->GetInvitees(int Limit = 0, FString Filter = "", FPubnubMemberSort Sort = ..., FPubnubPage Page = FPubnubPage());
```

#### Output

| Type | Description |
| --- | --- |
| `FPubnubChatMembershipsResult` | Returned object containing `Result` (`FPubnubChatOperationResult`), `Memberships` (`TArray<UPubnubChatMembership*>`), `Page`, and `Total`. |

### Sample code

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::GetInviteesSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// Callback for when the operation completes (returns invitees = members with pending status)
	FOnPubnubChatMembershipsResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatChannel::OnGetInviteesResponse);
	Channel->GetInviteesAsync(Callback);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnGetInviteesResponse(const FPubnubChatMembershipsResult& Result)
{
	if (Result.Result.Error) { return; }
	TArray<UPubnubChatMembership*> Memberships = Result.Memberships;
}
```

## Listen to invite events

Subscribe to real-time invitation events for a user with `StreamInvitations()`. Bind the user's `OnInvited` delegate before calling this method.

| Delegate | Type | Payload |
| --- | --- | --- |
| `OnInvited` | `FOnPubnubChatUserInvited` | `FPubnubChatInviteEvent` containing `ChannelType`, `ChannelID`, and `Event` details. |

### Method signature

```cpp
User->StreamInvitations();
```

#### Output

| Type | Description |
| --- | --- |
| `FPubnubChatOperationResult` | Contains `Error` and `ErrorMessage`. Check `Error` to determine if the subscription started successfully. |

### Sample code

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
void StreamInvitationsSample();

void OnUserInvited(const FPubnubChatInviteEvent& InviteEvent);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::StreamInvitationsSample()
{
	// snippet.hide
	UPubnubChatUser* User = nullptr;
	// snippet.show

	// Assumes User is a valid UPubnubChatUser (e.g. from GetCurrentUser)

	// Bind to receive invite events for this user
	User->OnInvitedNative.AddUObject(this, &ASample_ChatUser::OnUserInvited);

	// Start streaming invitation events
	User->StreamInvitationsAsync(nullptr);

	// When invitation events are no longer needed, stop streaming
	User->StopStreamingInvitationsAsync(nullptr);
}

// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::OnUserInvited(const FPubnubChatInviteEvent& InviteEvent)
{
	/* e.g. show channel invite notification in UI */
}
```

### Stopping updates

To stop receiving invitation events, call `StopStreamingInvitations()` on the user.

```cpp
User->StopStreamingInvitations();
```

#### Output

| Type | Description |
| --- | --- |
| `FPubnubChatOperationResult` | Contains `Error` and `ErrorMessage`. |