Restore messages

If you delete a message, you can restore its content together with the attached files using the Restore() method.

This is possible, however, only if the message you want to restore was soft deleted (the soft parameter was set to true when deleting it). Hard deleted messages cannot be restored as their data is no longer available in Message Persistence.

Requires Message Persistence configuration

To manage messages, you must enable Message Persistence for your app's keyset in the Admin Portal and mark the Enable Delete-From-History option.

Method signature

This method has the following signature:

message.Restore()

Input

This method doesn't take any parameters.

Output

This method doesn't return any data.

Basic usage

Restore a previously soft deleted message with the 16200000000000001 timetoken.

// reference the "channel" object
if (chat.TryGetChannel("support", out var channel))
{
Console.WriteLine($"Found channel with name {channel.Name}");

// invoke the method on the "channel" object to get message history
List<string> messages = channel.GetMessageHistory(
startTimeToken: "16200000000000000",
endTimeToken: "16200000000000001",
count: 1
);

// Find the specific message with the given timetoken
var message = messages[0];

show all 22 lines
Last updated on