Interface Conversation<ContentTypes>

Conversation represents either a V1 or V2 conversation with a common set of methods.

Type Parameters

  • ContentTypes = any

Hierarchy

  • Conversation

Implemented by

Properties

clientAddress: string

The wallet address connected to the client

Optional field containing the conversationId and metadata for V2 conversations. Will always be undefined on V1 conversations

conversationVersion: "v1" | "v2"
createdAt: Date

Timestamp the conversation was created at

ephemeralTopic: string

A unique identifier for ephemeral envelopes for a conversation.

peerAddress: string

The wallet address of the other party in the conversation

topic: string

A unique identifier for a conversation. Each conversation is stored on the network on one topic

Methods

  • Retrieve messages in this conversation. Default to returning all messages.

    If only a subset is required, results can be narrowed by specifying a start/end timestamp.

    // Get all messages in the past 24 hours
    const messages = await conversation.messages({
    startTime: new Date(+new Date() - 86_400)
    })

    Parameters

    Returns Promise<DecodedMessage<ContentTypes>[]>

  • Return a PreparedMessage that has contains the message ID of the message that will be sent.

    Parameters

    Returns Promise<PreparedMessage>

  • Return a Stream of new ephemeral messages from this conversation's ephemeral topic.

    Stream instances are async generators and can be used in for await statements.

    for await (const message of await conversation.streamEphemeral()) {
    console.log(message.content)
    }

    Returns Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>

  • Return a Stream of new messages in this conversation.

    Stream instances are async generators and can be used in for await statements.

    for await (const message of await conversation.stream()) {
    console.log(message.content)
    }

    Returns Promise<Stream<DecodedMessage<ContentTypes>, ContentTypes>>

Generated using TypeDoc