---
source_url: https://www.pubnub.com/docs/chat/unity-chat-sdk/learn/chat-entities/message-draft
title: MessageDraft object
updated_at: 2026-06-15T12:12:04.422Z
---

> 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


# MessageDraft object

`MessageDraft` represents a message that has not been published yet. Message drafts allow you to mention users, reference channels, and add URLs to a message.

## Properties

`MessageDraft` has the following properties:

```csharp
public class MessageDraft
{
    public string Text { get; }
    public List<MessageElement> MessageElements { get; }
    public bool ShouldSearchForSuggestions { get; set; }
    public List<ChatInputFile> Files { get; set; }
    public Message QuotedMessage { get; set; }
}
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| Text | string | Optional |  | The current text of the draft. |
| MessageElements | List<MessageElement> | Optional |  | The current message elements. |
| ShouldSearchForSuggestions | bool | Optional |  | Whether the `MessageDraft` should search for suggestions whenever the text is changed. |
| Files | List<ChatInputFile> | Optional |  | List of files to attach to the message. Refer to [Files](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/files) for more details. |
| QuotedMessage | Message | Optional |  | A message to [quote](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/quotes) in this draft. When set, the sent message will include the quoted message metadata. |

### Events

The `MessageDraft` object has the following events:

```csharp
// Event triggered when a message draft is updated
public event Action<List<MessageElement>, List<SuggestedMention>> OnDraftUpdated; 
```

#### Example

Insert suggested mentions when updating a message draft.

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

// 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;
}
// Get a channel and create a message draft
var channelResult = await chat.GetChannel("my_channel");
if (!channelResult.Error)
{
    var channel = channelResult.Result;
    var messageDraft = channel.CreateMessageDraft();
            
    messageDraft.ShouldSearchForSuggestions = true;

    messageDraft.OnDraftUpdated += (elements, mentions) =>
    {
        if (!mentions.Any())
        {
            return;
        }
        messageDraft.InsertSuggestedMention(mentions[0], mentions[0].ReplaceTo);
    };
}
```

## Methods

You can call the following methods on the `MessageDraft` object.

Click on each method for more details.

### Standard methods

* [AddMention()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#add-message-element)
* [AppendText()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#append-message-text)
* [GetMessageElements()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#get-message-elements)
* [InsertSuggestedMention()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#insert-suggested-message-element)
* [InsertText()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#insert-message-text)
* [RemoveMention()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#remove-message-element)
* [RemoveText()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#remove-message-text)
* [Send()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#send-a-draft-message)
* [Update()](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#update-message-text)

### Streaming methods

Real-time updates are delivered via a C# event listener that you subscribe to directly. The `OnDraftUpdated` event fires each time the draft content changes.

* [Add a message draft listener](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#add-message-draft-change-listener)
* [Remove a message draft listener](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#remove-message-draft-change-listener)

## Use case

`MessageDraft` methods enable users to prepare [draft messages](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/drafts#create-a-draft-message) with:

* [Links](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/messages/links)
* [User mentions](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/users/mentions) with `@`
* [Channel references](https://www.pubnub.com/docs/chat/unity-chat-sdk/build/features/channels/references) with `#`