Skip to main content

Use labels to differentiate multiple conversations between a pair of addresses

With XMTP, a pair of blockchain account addresses can have multiple ongoing conversations. In addition, with XMTP, an app can display all conversations a user has, regardless of the app they used to create the conversation. This concept is known as a portable, or universal, inbox.

Alternatively, an app can implement conversation IDs and metadata to filter conversations. For example, a developer can choose to assign app-specific conversation IDs and metadata to filter and display only conversations created by their app.

Apps that assign conversation IDs in this way have an effect on apps that use a portable inbox model. For example, a user might see multiple separate and ongoing conversations they are having with the same address, but originating in different apps.

If you're using a portable inbox model for your app, you can display conversation labels based on conversation IDs and metadata to help clarify the user experience.

To illustrate this scenario, let's take a look at a couple of conversations between amal.eth and bola.eth.

amal.eth and bola.eth can have an ongoing conversation in App ABC. Let's say that App ABC sets a conversationId of app.abc/dm and uses it to filter conversations to display only conversations its users created using App ABC.

Mockup of App ABC setting a conversation ID of app.abc/dm and filtering conversations by it. The app displays amal.eth's inbox with a "Hey..." conversation from bola.eth

amal.eth and bola.eth can also have a separate and ongoing conversation in App XYZ. Let's say that App XYZ sets a conversationId of app.xyz/dm and uses it to filter conversations to display only conversations its users created using App XYZ.

Mockup of App XYZ setting a conversation ID of app.xyz/dm and filtering conversations by it. The app displays amal.eth's inbox with a "Yes..." conversation from bola.eth

Let's then take a look at App 123, which doesn't filter conversations and displays all conversations for a user regardless of where the conversations were created. In this case, the inbox for amal.eth might look something like this:

Mockup of App 123 with no conversation ID or filtering. The app displays amal.eth's inbox with two conversations with bola.eth: One "Hey..." and one "Yes..."

This scenario may display a confusing user experience for amal.eth, surfacing two separate conversations they are having with the same address, bola.eth.

To help distinguish the multiple conversations amal.eth is having with the same address, you can implement labels, based on conversation IDs and metadata, that display for each conversation.

Mockup of App 123 with no conversation ID or filtering, but with conversation ID and metadata-based labels implemented. The app displays amal.eth's inbox with two conversations with bola.eth: One labeled as app.abc: "Hey..." and one labeled as app.xyz: "Yes..."

These labels can help amal.eth recognize the source of each conversation with bola.eth and understand why multiple conversations are displaying.

To use labels to differentiate multiple conversations between a pair of addresses:

Get the conversationId value to display as a label.

For example:

// To get the conversationId
const conversationId = conversation?.context?.conversationId

// Example conversationId = app.abc/dm/0x123-0x456

const domain = conversationId.split("/")[0]

// In this case, the domain is app.abc, which provides the conversation label

Learn more‚Äč

To learn more about conversation topics, see XMTP V2 topics and message presentation flow.