Quoted messages

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

Interactive demo​

See quoting and threads in a React app.

Want to implement something similar?

See how to or view the 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() adds a quoted message to a message draft.

Direct assignment

Alternatively, assign directly to messageDraft.quotedMessage.

Method signature​

1messageDraft.addQuote(message: Message): void;

Input​

* required
ParameterDescription
message *
Type: Message
Default:
n/a
Message 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.

Sample code​

Quote the message with the 16200000000000001 timetoken.

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

Get quoted message​

quotedMessage returns the original quoted message.

Method signature​

This method has the following signature:

1message.quotedMessage: {
2 timetoken: string,
3 text: string,
4 userId: string
5}

Properties​

PropertyDescription
timetoken
Type: string
Timetoken of the orginal message that you quote.
text
Type: string
Original message content.
userId
Type: string
Unique ID that identifies the user who published the quoted message.

Sample code​

Return a quote from the message with the 16200000000000001 timetoken.

1// return the message object
2const message = await channel.getMessage("16200000000000001")
3// return quote from the message
4message.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:

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

Remove quoted message​

removeQuote() removes the quote from a draft message.

Direct assignment

Alternatively, set messageDraft.quotedMessage = null.

Method signature​

This method has the following signature:

1messageDraft.removeQuote(): void;

Input​

This method doesn't take any parameters.

Output​

TypeDescription
voidMethod returns no output data.

Sample code​

Remove a quote from the draft message.

1messageDraft.removeQuote()

Was this page useful?

Last updated on