Skip to main content

Reply Content Type

Status Status

A reply is a method to directly respond to a specific message in a conversation. Users can select and reply to a particular message instead of sending a new one.

Open for feedback

You are welcome to provide feedback by commenting on the Reply Content Type XIP Proposal.

Configure content type

In some SDK's the ReplyCodec is already included in the SDK. If not, you can install the package using the following command:

In the javascript SDK you need to import this package first.

npm i @xmtp/content-type-reply

After importing the package you can register the codec.

import { ContentTypeReply, ReplyCodec } from "@xmtp/content-type-reply";
// Create the XMTP client
const xmtp = await Client.create(signer, { env: "dev" });
xmtp.registerCodec(new ReplyCodec());

Sending a Reply

Once you've created a reply, you can send it:

In XMTP, replies are represented as objects with two keys:

  • reference: The message ID for the message that is being replied to

  • content: A string representation of the reply

const reply: Reply = {
reference: someMessageID,
content: "I concur",
};

await conversation.send(reply, {
contentType: ContentTypeReply,
});

Receiving a Reply

Here's how you can receive a reply:

if (message.contentType.sameAs(ContentTypeReply)) {
// We've got a reply.
const reply: Reply = message.content;
}

Displaying the Reply

The presentation of replies are decisions to be made by client applications. It does seem worth it to call out some reply experiences that we use today that might map well to the above proposal. They are:

  • Discord Individual messages can get replied to, where the replies retain a link back to the originally referenced message
  • Telegram

Note that iMessage and Slack are omitted, as they follow more of a “threaded” pattern, where messages are collected into a logical grouping. There may be a separate content type proposal to explore this as a pattern, so for now, we’ll hold off.

Was the information on this page helpful?
powered by XMTP