🎭Request Inbox

Learn how you can build and split your request inbox by using Airstack to determine if a user can be considered a real user or not in your XMTP messaging app.

The request inbox is for users unknown to the main user and without any connections. It typically holds spam, which users should avoid.

There could also occasionally be real users with no connections who might want to contact the main user. To manage this, we recommend dividing the request inbox even further into two parts:

  • Top Requests: This includes likely real users from the request inbox.

  • All Requests: This contains all users in the request inbox, without filtering.

Use the Airstack API to check if senders in the request inbox are genuine and place them in the Top Requests Inbox.

Some criteria that can be checked for splitting the request inbox:

  • Senders Have Non-Virtual POAPs (IRL POAPs can only be minted in person, so this is a strong positive signal)

  • Senders have X number of followers on Farcaster (e.g. if the user has >1000 followers you may have some confidence they are a real user)

  • Senders have X number of followers on Lens

  • Senders have/have not sent tokens/NFTs previously (If the user has no wallet history it's a strong negative signal)

  • Senders hold some tokens/NFTs (If the user has no wallet history it's a strong negative signal)

Table Of Contents

In this guide, you will learn how to use Airstack to create a request inbox by:

Pre-requisites

  • An Airstack account

  • Basic knowledge of GraphQL

  • Basic knowledge of XMTP

Get Started

JavaScript/TypeScript/Python

If you are using JavaScript/TypeScript or Python, Install the Airstack SDK:

React

npm install @airstack/airstack-react

Node

npm install @airstack/node

Then, add the following snippets to your code:

import { init, useQuery } from "@airstack/airstack-react";

init("YOUR_AIRSTACK_API_KEY");

const query = `YOUR_QUERY`; // Replace with GraphQL Query

const Component = () => {
  const { data, loading, error } = useQuery(query);

  if (data) {
    return <p>Data: {JSON.stringify(data)}</p>;
  }

  if (loading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }
};

Other Programming Languages

To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.

πŸ€– AI Natural Language​

Airstack provides an AI solution for you to build GraphQL queries to fulfill your use case easily. You can find the AI prompt of each query in the demo's caption or title for yourself to try.

Best Practice

While choosing a specific criteria will significantly decrease the number of spam appearing on your user's XMTP inbox, It is best practice that you combine the multiple criterion given here to build and split your Request Inbox.

This is done to provide multiple layers of filtration that will make it nearly impossible for spammers to have their messages slide into your users' XMTP inbox.

Check If Senders Have Any Token Transfers

You can check if senders have sent any token by providing an array of senders' 0x addresses to the $senders variable using the TokenTransfers API:

You can use this query to filter senders on the fly with a maximum of 200 wallet inputs to the $senders variable per API call.

Try Demo

Code

query GetTokenTransfers($senders: [Identity!]) {
  ethereum: TokenTransfers(
    input: {
      filter: { from: { _in: $senders } }
      blockchain: ethereum
      order: { blockTimestamp: DESC }
    }
  ) {
    TokenTransfer {
      transactionHash
      from {
        addresses
      }
    }
  }
  base: TokenTransfers(
    input: {
      filter: { from: { _in: $senders } }
      blockchain: base
      order: { blockTimestamp: DESC }
    }
  ) {
    TokenTransfer {
      transactionHash
      from {
        addresses
      }
    }
  }
  zora: TokenTransfers(
    input: {
      filter: { from: { _in: $senders } }
      blockchain: zora
      order: { blockTimestamp: DESC }
    }
  ) {
    TokenTransfer {
      transactionHash
      from {
        addresses
      }
    }
  }
}

Check If Senders Have Any Token Balances

You can check if senders hold any token in their wallet across multiple chains, e.g. Ethereum, Polygon, Base, or Zora, by providing an array of senders' 0x addresses to the $senders variable using the TokenBalances API:

You can use this query to filter senders on the fly with a maximum of 200 wallet inputs to the $senders variable per API call.

Try Demo

Code

query MyQuery($senders: [Identity!]) {
  # Ethereum token balances
  Ethereum: TokenBalances(
    input: {
      filter: { owner: { _in: $senders } }
      blockchain: ethereum
      limit: 50
    }
  ) {
    TokenBalance {
      tokenAddress
      owner {
        addresses
      }
    }
  }
  # Base token balances
  Base: TokenBalances(
    input: {
      filter: { owner: { _in: $senders } }
      blockchain: base
      limit: 50
    }
  ) {
    TokenBalance {
      tokenAddress
      owner {
        addresses
      }
    }
  }
  # Zora token balances
  Zora: TokenBalances(
    input: {
      filter: { owner: { _in: $senders } }
      blockchain: zora
      limit: 50
    }
  ) {
    TokenBalance {
      tokenAddress
      owner {
        addresses
      }
    }
  }
}

Check If Senders Have Any Non-Virtual POAPs

You can check if senders have attended any non-virtual POAPs by providing an array of senders' 0x addresses to the $senders variable using the Poaps API:

You can use this query to filter senders on the fly with a maximum of 200 wallet inputs to the $senders variable per API call.

Try Demo

Code

query POAPsOwned($senders: [Identity!]) {
  Poaps(
    input: { filter: { owner: { _in: $senders } }, blockchain: ALL, limit: 50 }
  ) {
    Poap {
      mintOrder
      mintHash
      poapEvent {
        isVirtualEvent
      }
      owner {
        addresses
      }
    }
    pageInfo {
      nextCursor
      prevCursor
    }
  }
}

Check If Senders Have X or More Followers on Lens

You can check if senders have X or more Lens followers by providing an array of senders' 0x addresses to the $senders variable using the Socials API:

You can use this query to filter senders on the fly with a maximum of 200 wallet inputs to the $senders variable per API call.

Try Demo

Code

query MyQuery($xmtpUsers: Identity!) {
  Socials(
    input: {
      filter: {
        followerCount: { _gt: 100 }
        dappName: { _eq: lens }
        identity: { _in: $senders }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      followerCount
    }
  }
}

Check If Senders Have X or More Followers on Farcaster

You can check if senders have X or more Farcaster followers by providing an array of senders' 0x addresses to the $senders variable using the Socials API:

You can use this query to filter senders on the fly with a maximum of 200 wallet inputs to the $senders variable per API call.

Try Demo

Code

query MyQuery($senders: [Identity!]) {
  Socials(
    input: {
      filter: {
        followerCount: { _gt: 100 }
        dappName: { _eq: farcaster }
        identity: { _in: $senders }
      }
      blockchain: ethereum
      limit: 200
    }
  ) {
    Social {
      followerCount
      userAddress
    }
  }
}

Developer Support

If you have any questions or need help regarding creating a request inbox on your XMTP messaging app, please join our Airstack's Telegram group.

More Resources

Last updated

Was this helpful?