---
title: "Twitter / X Plugin"
sidebarTitle: "Twitter"
description: "Twitter/X connector for Eliza — posting, replying, monitoring mentions, and timeline interactions via the xAI plugin."
---

> **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](https://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

| Field | Required | Description |
|-------|----------|-------------|
| `apiKey` | Yes | Twitter API key (consumer key) |
| `apiSecretKey` | Yes | Twitter API secret key (consumer secret) |
| `accessToken` | Yes | OAuth 1.0a access token |
| `accessTokenSecret` | Yes | OAuth 1.0a access token secret |
| `enabled` | No | Set `false` to disable (default: `true`) |
| `postEnable` | No | Enable automated posting (default: `true`) |
| `postIntervalMin` | No | Minimum minutes between posts (default: `90`) |
| `postIntervalMax` | No | Maximum minutes between posts (default: `180`) |
| `searchEnable` | No | Enable keyword search monitoring (default: `false`) |
| `autoRespondMentions` | No | Automatically respond to @mentions (default: `true`) |
| `dryRun` | No | Generate 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](https://developer.twitter.com/en/docs/twitter-api/rate-limits) for current numbers before choosing a tier.

## Related

- [Twitter Connector Reference](/connectors/twitter) — Full configuration reference (cookie auth, DM policy, timeline interactions)
- [Discord Plugin](/plugin-registry/platform/discord) — Discord bot integration
- [Farcaster Plugin](/plugin-registry/platform/farcaster) — Decentralized social alternative
- [Connectors Guide](/guides/connectors) — General connector documentation
