The Upstreet Agents SDK is now in public beta 🎉 Get started →
bg-pattern
📚 API ReferencePlugins

X (formerly Twitter)

Integrate your Agent with X, one of the world's most viral social apps.

Responding to Mentions

Twitter integration allows your agent to interact with Twitter by responding to mentions.

  1. Create a Twitter Developer Account:

  2. Configure your application:

    • Navigate to the "Settings" tab of your application
    • Under the "User authentication settings" section, press the "Edit" button
    • In the "App Permissions" section, select the appropriate option having "write" access
    • In the "Type of App" section, you must select the "Native app" (Public client) option
    • In the "App Info" section:
    • Once completed, save your changes by clicking the "Save" button
    • Navigate to the "Keys and tokens" section
    • Copy your OAuth 2.0 application credentials (Client ID and Client Secret)
  3. Log in with oauth at https://twitter-auth.upstreet.ai/

    • Use the Client ID and Client Secret from step 2
    • On successful authentication, you will be provided with your Twitter Token
    • Copy the token and use it in the next step
  4. Configure your agent:

    • Add the following component to your agent:
    import { Twitter } from 'react-agents';
     
    return (
      <Agent>
        {/* ... */}
        <Twitter
          token="YOUR_TWITTER_TOKEN" // Paste your Twitter Token from Step 3. here
        />
        {/* ... */}
      </Agent>
    );

    Additional Notes:

    • The bot will automatically listen for and respond to mentions of your Twitter account
    • The token should be kept secure and not committed to version control
      • You can use .env.txt and the useEnv() hook to load it at runtime
    • The bot polls for new mentions every 10 seconds
    • Twitter API rate limits apply - see Twitter's developer documentation for details
    • The bot requires a stable internet connection to maintain communication with Twitter
    • Note: if you haven't created the agent yet, please follow this Create an Agent first.

Twitter Spaces

The Twitter Spaces integration allows your agent to create and join Twitter Spaces audio rooms.

  1. Get your Twitter auth token:

    • Log into Twitter in your browser
    • Open the browser developer tools (F12)
    • Go to the Application/Storage tab
    • Find the auth_token cookie under Cookies > twitter.com
    • Copy the value of the auth_token cookie
  2. Configure your agent:

    import { TwitterSpaces } from 'react-agents';
     
    return (
      <Agent>
        {/* ... */}
        <TwitterSpaces
          token="YOUR_AUTH_TOKEN" // Twitter auth_token cookie value
          url="OPTIONAL_SPACE_URL" // URL of an existing Space to join (optional)
        />
        {/* ... */}
      </Agent>
    );

    Additional Notes:

    • If no url is provided, the bot will create a new Twitter Space
    • If a url is provided, the bot will attempt to join that existing Space
    • The bot will automatically:
      • Create/join the Space
      • Request speaking permissions if joining
      • Unmute itself when ready
    • The token should be kept secure and not committed to version control
      • You can use .env.txt and the useEnv() hook to load it at runtime
    • The bot requires a stable internet connection to maintain the Space connection
    • Twitter's standard rate limits and Space restrictions apply
    • Note: if you haven't created the agent yet, please follow this Create an Agent first.

On this page

Facing an issue? Add a ticket.