---
source_url: https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/messages/forward
title: Forward messages
updated_at: 2026-05-19T12:10:33.573Z
---

> 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


# Forward messages

Forward messages between channels to share information or facilitate collaboration.

##### 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. 1Message->ForwardAsync(Channel, OnForwardResponseDelegate); You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubChatOperationResponseNative).
* Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly. 1FPubnubChatOperationResult Result = Message->Forward(Channel);
:::

Use `Forward()` on a message object or `ForwardMessage()` on a channel/chat object. Both produce the same result with different input parameters.

:::note Additional info in the forwarded message
Forwarded messages include `originalPublisher` (original sender's user ID) and `originalChannelId` (source channel ID).
:::

### Method signature

* Message->Forward() 1Message->Forward(UPubnubChatChannel* Channel);
* Channel->ForwardMessage() 1Channel->ForwardMessage(UPubnubChatMessage* Message);
* Chat->ForwardMessage() 1Chat->ForwardMessage(2 UPubnubChatMessage* Message,3 UPubnubChatChannel* Channel4);

| Parameter | Required in Message->Forward() | Required in Channel->ForwardMessage() | Required in Chat->ForwardMessage() | Description |
| --- | --- | --- | --- | --- |
| Channel | UPubnubChatChannel* | Optional |  | Yes | No | Yes | [Channel object](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/channel) to which you want to forward the message. You can forward a message to the same channel on which it was published or to any other. |
| Message | UPubnubChatMessage* | Optional |  | No | Yes | Yes | [Message object](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/message) that you want to forward to the selected channel. |

#### Output

| Method | Return type |
| --- | --- |
| `Message->Forward()` | `FPubnubChatOperationResult` |
| `Channel->ForwardMessage()` | `FPubnubChatOperationResult` |
| `Chat->ForwardMessage()` | `FPubnubChatOperationResult` |

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

Forward a message to another channel asynchronously.

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatMessage")
void ForwardMessageSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatMessage with name of your Actor class
void ASample_ChatMessage::ForwardMessageSample()
{
	// snippet.hide
	UPubnubChatMessage* Message = nullptr;
	// snippet.show

	// Assumes Message is a valid UPubnubChatMessage

	// Target channel to forward this message to
	UPubnubChatChannel* TargetChannel = nullptr;

	// Forward the message to the target channel (publishes with forwarding metadata)
	Message->ForwardAsync(TargetChannel, nullptr);
}
```

### Other examples

#### Forward from channel

###### Actor.h

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

###### Actor.cpp

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

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

	// Message to forward; must be from a different channel (e.g. from another channel's history)
	UPubnubChatMessage* Message = nullptr;

	// Forward a message to this channel (publishes with forwarding metadata)
	Channel->ForwardMessageAsync(Message, nullptr);
}
```

#### Forward from chat

###### Actor.h

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

UFUNCTION()
void OnForwardMessageResponse(const FPubnubChatOperationResult& Result);
```

###### Actor.cpp

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

	// Assumes Chat is a valid and initialized instance of UPubnubChat
	
	// Message: the message to forward (e.g. from channel listeners or from history)
	UPubnubChatMessage* Message = nullptr;
	// TargetChannel: the channel to forward to (must be different from the message's channel)
	UPubnubChatChannel* TargetChannel = nullptr;

	FOnPubnubChatOperationResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnForwardMessageResponse);
	Chat->ForwardMessageAsync(Message, TargetChannel, Callback);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnForwardMessageResponse(const FPubnubChatOperationResult& Result)
{
	if (Result.Error) { return; }
	// Forward completed
}
```