SDKsHarmonyOSEnterprise
Create advanced quote message
Quote an existing message with rich entity spans attached to the reply text.
Creates a quote message referencing an existing message while supporting embedded rich text entities (such as links or mentions) in the reply body.
Code example
import sdk, {
CreateAdvancedQuoteMessageReq,
CreateAdvancedQuoteMessageResp,
MessageEntity,
} from '@openimsdk/imsdk';
const entity: MessageEntity = {
type: 'url',
offset: 3,
length: 4,
url: 'https://example.com/task/42',
ex: '',
};
const request: CreateAdvancedQuoteMessageReq = {
text: 'View task details',
quoteMessage: originalMessage,
messageEntities: [entity],
};
const response: CreateAdvancedQuoteMessageResp = await sdk.createAdvancedQuoteMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Reply body text. |
quoteMessage | IMMessage | Yes | The original message being quoted. |
messageEntities | MessageEntity[] | Yes | Array of rich entity spans within the reply text. |
Return value
Returns a Promise resolving to CreateAdvancedQuoteMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally constructed advanced quote message object ready to send. |
State changes after the call
Entity offsets and lengths must fall strictly within the bounds of text. The quoted message must belong to the destination conversation. Receiving clients should validate boundaries, URLs, and extension data. This method creates the message object locally without modifying the quoted message or initiating network requests. Call Send message to dispatch it.
Was this page helpful?