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.
Direct assignment
You can also directly assign a Message object to the quotedMessage property of the MesssageDraftV2 object.
Method signature
1messageDraft.addQuote(message: Message): void;
Input
| Parameter | Description |
|---|---|
message *Type: MessageDefault: n/a | Message you want to quote. |
Output
| Type | Description |
|---|---|
void | Method 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 is a getter method that lists 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
| Property | Description |
|---|---|
timetokenType: string | Timetoken of the orginal message that you quote. |
textType: string | Original message content. |
userIdType: 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() lets you remove the quote from the draft message.
Direct assignment
You can also directly pass null to the quotedMessage property of the MesssageDraftV2 object to remove a quoted message.
Method signature
This method has the following signature:
1messageDraft.removeQuote(): void;
Input
This method doesn't take any parameters.
Output
| Type | Description |
|---|---|
void | Method returns no output data. |
Sample code
Remove a quote from the draft message.
1messageDraft.removeQuote()