Skip to content

getXmtpFrameMessage

Frames can receive interactions from apps outside of Farcaster, such as from XMTP conversations. When receiving these interactions you can expect a slightly different response format, since fields like fid or castId are not available.

You can also use getXmtpFrameMessage to access useful information such as:

  • buttonIndex: number
  • verifiedWalletAddress: string
  • opaqueConversationIdentifier: string

Note that if the message is not valid, it will be undefined.

import { isXmtpFrameRequest, getXmtpFrameMessage } from '@coinbase/onchainkit/xmtp'; 
import { NextResponse } from 'next/server';
import type { FrameRequest } from '@coinbase/onchainkit/frame';
 
async function getResponse(req: any): Promise<NextResponse> {
  const body: FrameRequest = await req.json();
  if (isXmtpFrameRequest(body)) {
    const { isValid, message } = await getXmtpFrameMessage(body); 
    // ... do something with the message if isValid is true
    if (isValid) {
      const { verifiedWalletAddress } = message;
      // ... do something with the verifiedWalletAddress
    }
  } else {
    // ...
  }
}

Returns

Promise<XmtpFrameValidationResponse>

Parameters

Promise<XmtpFramesRequest>