How to create a new direct message to an Address

Hi! I really need some help here — I’ve been stuck on this forever while trying to update my dApp from XMTP v2 to v3.

I understand that addresses are part of an inbox’s identities, and I’m already able to get an address from an inboxId.

What I’m trying to do is start a conversation with an address, even if I don’t know the inboxId (as long as the address is already registered).

Please, please, please help!:face_with_monocle: :face_with_peeking_eye: :upside_down_face:

11 Likes

Yes, you can absolutely still do that. You can create conversations with “identifiers”, and those identifiers can be ETH addresses.

You can see some code examples in our docs here

9 Likes

Hello there!

I can see why it may be confusing, as all of our default createGroup / createDM functions take inboxID as parameters. However, we also have equivalent newGroupWithIdentifiers / newDmWithIdentifier functions that take as a parameter an Identifier object (or an array of them for groups). For example in our browser-sdk, the identifier object looks like this:

export interface Identifier {
    identifier: string;
    identifierKind: IdentifierKind;
}

export type IdentifierKind = "Ethereum" | "Passkey";

So in our using our browser-sdk you could create a conversation with an eth address “0x235017975ed5F55e23a71979697Cd67DcAE614Fa” using the following code:

const directMessage = await client.conversations.newDmWithIdentifier({
            identifier: address.toLowerCase(),
            identifierKind: "Ethereum",
});

Hopefully that helps! Also to double check if a address is registered on the network, see docs here: Create conversations – Build with XMTP

9 Likes

Message me on mmdrops.eth

7 Likes