---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/quotes
title: Quoted messages
updated_at: 2026-05-25T11:25:51.814Z
---

> 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


# Quoted messages

Quote previous messages to provide context when responding to older messages in a conversation.

## Quote message

Set the `QuotedMessage` property on a [MessageDraft](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts) before sending it. The quoted message metadata (timetoken, text, and user ID) is automatically included when the draft is published.

### Method signature

Head over to the [MessageDraft](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#quote-a-message-in-a-draft) documentation for details.

### Sample code

Quote a message with the `16200000000000001` timetoken.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
var quotedMessageResult = await chat.GetMessage("support", "16200000000000001");
if(quotedMessageResult.Error)
{
    return;
}
var quotedMessage = quotedMessageResult.Result;
        
var channelResult = await chat.GetChannel("support");
if (channelResult.Error)
{
    Debug.LogError($"Couldn't get channel, error: {channelResult.Exception.Message}");
    return;
}
var testChannel = channelResult.Result;
        
//Creating a Message Draft to attatch a Quote
var messageDraft = testChannel.CreateMessageDraft();
messageDraft.InsertText(0, "message with a quote");
messageDraft.QuotedMessage = quotedMessage;
        
await messageDraft.Send();
```

## Get quoted message

`GetQuotedMessage()` returns the original quoted message.

### Method signature

This method has the following signature:

```csharp
message.GetQuotedMessage()
```

#### Input

This method doesn't take any parameters.

#### Output

| Type | Description |
| --- | --- |
| `Task<ChatOperationResult<Message>>` | An awaitable `Task` with the `Message` object if a quote exists, otherwise the `Error` property on the result will be `true`. |

### Sample code

Return a quote from the message with the `16200000000000001` timetoken.

```csharp
using System.Threading.Tasks;
using PubnubApi;
using PubnubChatApi;
using UnityEngine;

// Configuration
PubnubChatConfig chatConfig = new PubnubChatConfig();
        
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize Unity Chat
var chatResult = await UnityChat.CreateInstance(chatConfig, pnConfiguration);
if (!chatResult.Error)
{
    chat = chatResult.Result;
}
var channelId = "support";
var messageTimeToken = "16200000000000001";

// retrieve the channel details
var channelResult = await chat.GetChannel(channelId);
if (!channelResult.Error)
{
    var channel = channelResult.Result;
    Debug.Log($"Found channel with name {channel.Name}");

    // retrieve the specific message by its timetoken
    var messageResult = await channel.GetMessage(messageTimeToken);
    if (!messageResult.Error) 
    {
        var message = messageResult.Result;
        // try to get the quoted message
        var quotedMessageResult = await message.GetQuotedMessage();
        if (!quotedMessageResult.Error)
        {
            var quotedMessage = quotedMessageResult.Result;
            Debug.Log($"Quoted message: {quotedMessage.MessageText}");
        }
        else
        {
            Debug.Log("No quoted message found.");
        }
    }
    else
    {
        Debug.Log("Message not found.");
    }
}
else
{
    Debug.Log("Channel not found.");
}
```