Back to Eliza

Twitter / X Plugin

packages/docs/plugin-registry/platform/twitter.md

2.0.14.9 KB
Original Source

Registry note: @elizaos/plugin-x is not currently listed in the Eliza plugin registry (plugins.json). The package may be available from npm or a separate elizaOS plugin repository. Verify availability before configuring.

The Twitter plugin connects Eliza agents to Twitter/X, enabling autonomous posting, replying to mentions, monitoring timelines, and engaging with other accounts.

On-demand plugin. This plugin is resolved from the remote elizaOS plugin registry and auto-installs when its credentials are detected. It is not included in Eliza's bundled plugins.json index.

Package: @elizaos/plugin-x

<Note> The separate `@elizaos/plugin-xai` package also bundles X/Twitter integration alongside Grok models. If you already use xAI with `X_*` env vars, you may not need to install this connector separately. </Note>

Installation

bash
# Requires the package to be available on npm
eliza plugins install twitter

Setup

1. Create a Twitter Developer Account

  1. Go to developer.twitter.com
  2. Apply for a developer account if you do not have one
  3. Create a new project and app
  4. Set the app permissions to Read and Write (required for posting)
  5. Generate your API keys and tokens

2. Configure Eliza

json
{
  "connectors": {
    "twitter": {
      "apiKey": "YOUR_API_KEY",
      "apiSecretKey": "YOUR_API_SECRET",
      "accessToken": "YOUR_ACCESS_TOKEN",
      "accessTokenSecret": "YOUR_ACCESS_TOKEN_SECRET"
    }
  }
}

Configuration

FieldRequiredDescription
apiKeyYesTwitter API key (consumer key)
apiSecretKeyYesTwitter API secret key (consumer secret)
accessTokenYesOAuth 1.0a access token
accessTokenSecretYesOAuth 1.0a access token secret
enabledNoSet false to disable (default: true)
postEnableNoEnable automated posting (default: true)
postIntervalMinNoMinimum minutes between posts (default: 90)
postIntervalMaxNoMaximum minutes between posts (default: 180)
searchEnableNoEnable keyword search monitoring (default: false)
autoRespondMentionsNoAutomatically respond to @mentions (default: true)
dryRunNoGenerate posts without publishing them (default: false)
json
{
  "connectors": {
    "twitter": {
      "apiKey": "...",
      "apiSecretKey": "...",
      "accessToken": "...",
      "accessTokenSecret": "...",
      "postIntervalMin": 60,
      "postIntervalMax": 120,
      "autoRespondMentions": true,
      "searchEnable": true
    }
  }
}

Features

  • Posting — Autonomous tweet generation based on character personality
  • Replies — Responds to @mentions in the agent's timeline
  • Quote tweets — Can quote-tweet with commentary
  • Search monitoring — Monitor keywords and hashtags
  • Timeline reading — Process home timeline for context
  • Media — Post images and videos alongside text
  • Thread support — Creates multi-tweet threads for long responses
  • Rate limit management — Automatically respects Twitter API rate limits

Autonomous Posting

When configured, the agent posts autonomously at random intervals within the configured range. Posts are generated by the LLM using the character's voice and personality.

The posting loop:

  1. Runtime waits a random interval between postIntervalMin and postIntervalMax minutes
  2. LLM generates a tweet in the character's voice
  3. Tweet is reviewed against content policies
  4. Tweet is posted to Twitter/X
  5. Interaction cycle repeats

Reply Flow

@mention or DM received
       ↓
Plugin fetches conversation context
       ↓
AgentRuntime processes with full thread context
       ↓
Response generated
       ↓
Posted as reply to original tweet

Enabling

After installation, the plugin loads when connectors.twitter contains apiKey. Unlike bundled connectors, it does not auto-enable from config alone — it must be installed first.

Environment Variables

The plugin also reads TWITTER_API_KEY, TWITTER_API_SECRET_KEY, TWITTER_ACCESS_TOKEN, and TWITTER_ACCESS_TOKEN_SECRET as fallbacks when the corresponding config fields are absent. Config fields take precedence.

Rate Limits

Twitter enforces strict rate limits on the v2 API. The plugin manages these automatically. Limits change frequently — check the X developer documentation for current numbers before choosing a tier.