Skip to content

MessageContext

Defined in: sdks/agent/src/core/MessageContext.ts:29

A message and its client for agent middleware.

Content = unknown

ContentTypes = unknown

new MessageContext<Content, ContentTypes>(__namedParameters): MessageContext<Content, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:36

Create a context for the received message and its conversation.

MessageContextParams<Content, ContentTypes>

MessageContext<Content, ContentTypes>

ConversationContext.constructor

get client(): Client

Defined in: sdks/agent/src/core/ClientContext.ts:23

Return the wrapped XMTP client.

Client

ConversationContext.client


get content(): Content

Defined in: sdks/agent/src/core/MessageContext.ts:137

The decoded value selected by the content type.

Content

set content(value): void

Defined in: sdks/agent/src/core/MessageContext.ts:128

Replace the middleware value without changing the SDK message.

Content

void


get conversation(): ConversationType

Defined in: sdks/agent/src/core/ConversationContext.ts:61

Return the conversation that triggered this context.

ConversationType

ConversationContext.conversation


get message(): Message

Defined in: sdks/agent/src/core/MessageContext.ts:133

The SDK message, including its tagged content and retained bytes.

Message

consentState(): Promise<ConsentState>

Defined in: sdks/agent/src/core/ConversationContext.ts:66

Return the conversation consent state.

Promise<ConsentState>

ConversationContext.consentState


getClientAddress(): string

Defined in: sdks/agent/src/core/ClientContext.ts:18

Return the account identifier used by the client, when available.

string

ConversationContext.getClientAddress


getSenderAddress(): Promise<string | undefined>

Defined in: sdks/agent/src/core/MessageContext.ts:120

Return the first identity identifier for the sender inbox.

Promise<string | undefined>


isAllowed(): Promise<boolean>

Defined in: sdks/agent/src/core/ConversationContext.ts:72

Whether the conversation consent state is allowed.

Promise<boolean>

ConversationContext.isAllowed


isDenied(): Promise<boolean>

Defined in: sdks/agent/src/core/ConversationContext.ts:77

Whether the conversation consent state is denied.

Promise<boolean>

ConversationContext.isDenied


isDm(): this is ConversationContext<ContentTypes, Dm>

Defined in: sdks/agent/src/core/ConversationContext.ts:38

Narrow this context to a direct-message conversation.

this is ConversationContext<ContentTypes, Dm>

ConversationContext.isDm


isGroup(): this is ConversationContext<ContentTypes, Group>

Defined in: sdks/agent/src/core/ConversationContext.ts:43

Narrow this context to a group conversation.

this is ConversationContext<ContentTypes, Group>

ConversationContext.isGroup


isMarkdown(): this is MessageContext<string, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:51

Narrow this context to a Markdown message.

this is MessageContext<string, ContentTypes>


isReaction(): this is MessageContext<Reaction, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:72

Narrow this context to a reaction message.

this is MessageContext<Reaction, ContentTypes>


isReadReceipt(): this is MessageContext<undefined, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:76

Narrow this context to a read receipt.

this is MessageContext<undefined, ContentTypes>


isRemoteAttachment(): this is MessageContext<RemoteAttachment, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:80

Narrow this context to a remote attachment.

this is MessageContext<RemoteAttachment, ContentTypes>


isReply(): this is MessageContext<{ body: MessageBody; kind: "reply"; referenceId: string }, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:59

Narrow this context to a reply message.

this is MessageContext<{ body: MessageBody; kind: "reply"; referenceId: string }, ContentTypes>


isText(): this is MessageContext<string, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:55

Narrow this context to a text message.

this is MessageContext<string, ContentTypes>


isTransactionReference(): this is MessageContext<TransactionReference, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:84

Narrow this context to a transaction reference.

this is MessageContext<TransactionReference, ContentTypes>


isUnknown(): Promise<boolean>

Defined in: sdks/agent/src/core/ConversationContext.ts:82

Whether the conversation consent state is unknown.

Promise<boolean>

ConversationContext.isUnknown


isWalletSendCalls(): this is MessageContext<WalletSendCalls, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:91

Narrow this context to wallet send calls.

this is MessageContext<WalletSendCalls, ContentTypes>


sendMarkdownReply(markdown): Promise<void>

Defined in: sdks/agent/src/core/MessageContext.ts:112

Send a Markdown reply to this message with push disabled.

string

Promise<void>


sendReaction(content, schema?): Promise<void>

Defined in: sdks/agent/src/core/MessageContext.ts:95

Send a reaction to this message with push disabled.

string

ReactionSchema = "unicode"

Promise<void>


sendRemoteAttachment(unencryptedFile, uploadCallback?): Promise<void>

Defined in: sdks/agent/src/core/ConversationContext.ts:48

Encrypt and send a remote attachment through the supplied upload callback.

File

AttachmentUploadCallback

Promise<void>

ConversationContext.sendRemoteAttachment


sendTextReply(text): Promise<void>

Defined in: sdks/agent/src/core/MessageContext.ts:116

Send a text reply to this message with push disabled.

string

Promise<void>


usesCodec<T>(codecClass): this is MessageContext<ReturnType<T["decode"]>, ContentTypes>

Defined in: sdks/agent/src/core/MessageContext.ts:45

Check the codec authority, type name, and major version.

T extends AnyContentCodec

() => T

this is MessageContext<ReturnType<T["decode"]>, ContentTypes>