Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Create advanced quote message

Quote an existing message with rich entity spans attached to the reply text.

Copy

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

ParameterTypeRequiredDescription
textstringYesReply body text.
quoteMessageIMMessageYesThe original message being quoted.
messageEntitiesMessageEntity[]YesArray of rich entity spans within the reply text.

Return value

Returns a Promise resolving to CreateAdvancedQuoteMessageResp:

PropertyTypeDescription
messageIMMessageLocally 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.