Quoted messages

Quoted Messages feature lets users reference previous messages within a conversation. By quoting a message, users can provide additional context or relevant details, ensuring coherence even when referencing older messages.

Interactive demo

Check how a sample implementation could look like in a React app showcasing how to quote messages sent by others and reply to them in threads.

Want to implement something similar?

Read how to do that or go straight to the demo's source code.

Test it out

Click Reset App State Globally to clear all previously added quotes and replies (if there are any).

Quote a sample message by pressing the Quote button, type in a reply, and press the arrow to send it.

Quote message

addQuote() lets you quote the chosen message in a message draft and respond to it. The quoted message will be displayed with no trimming.

Method signature

messageDraft.addQuote(message: Message): void;

Input

ParameterTypeRequiredDefaultDescription
messageMessageYesn/aMessage you want to quote.

Output

TypeDescription
voidMethod returns no output data.

Errors

You will receive the You cannot quote messages from other channels error whenever you try to quote a message from another channel.

Basic Usage

Quote the message with the 16200000000000001 timetoken.

// return the message object
const message = await channel.getMessage("16200000000000001")
//add quote to the message
messageDraft.addQuote(message)

Get quoted message

quotedMessage is a getter method that lists the original quoted message.

Method signature

This method has the following signature:

message.quotedMessage: {
timetoken: string,
text: string,
userId: string
}

Properties

PropertyTypeDescription
timetokenstringTimetoken of the orginal message that you quote.
textstringOriginal message content.
userIdstringUnique ID that identifies the user who published the quoted message.

Basic usage

Return a quote from the message with the 16200000000000001 timetoken.

// return the message object
const message = await channel.getMessage("16200000000000001")
// return quote from the message
message.quotedMessage

quotedMessage returns only values for the timetoken, text, and userId parameters. If you want to return the full quoted Message object, use the getMessage() method and the timetoken from the quote that you can extract from the quotedMessage parameter added to the published message:

const quotedMessageObject = await channel.getMessage(quotedMessage.timetoken)

Remove quoted message

removeQuote() lets you remove the quote from the draft message.

Method signature

This method has the following signature:

messageDraft.removeQuote(): void;

Input

This method doesn't take any parameters.

Output

TypeDescription
voidMethod returns no output data.

Basic Usage

Remove a quote from the draft message.

messageDraft.removeQuote()
Last updated on