Back to Eliza

Twitter/X Connector

packages/docs/connectors/twitter.md

2.0.16.5 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.

Connect your agent to Twitter/X for social media engagement.

Availability: @elizaos/plugin-x is an on-demand elizaOS plugin resolved from the remote plugin registry. It is not included in Eliza's bundled plugins.json index. The plugin auto-installs at runtime when a valid token is detected in your connector configuration.

Overview

The Twitter connector is an elizaOS plugin that bridges your agent to Twitter/X. It is auto-enabled by the runtime when a valid token is detected in your connector configuration.

Installation

bash
eliza plugins install @elizaos/plugin-x

Configuration

FieldValue
Package@elizaos/plugin-xai
Config keyconnectors.twitter
Auto-enable triggerapiKey, token, or X OAuth env vars (X_API_KEY, etc.)
<Note> `@elizaos/plugin-x` is the dedicated Twitter connector and handles posting, mentions, and timeline interactions. The separate `@elizaos/plugin-xai` package also includes X/Twitter integration alongside Grok model access — if you already have xAI configured with `X_*` env vars, you may not need this connector separately. </Note>

Minimal Configuration

The connector auto-enables when botToken, token, or apiKey is truthy in the connector config and enabled is not explicitly false.

Configure in ~/.eliza/eliza.json:

json
{
  "connectors": {
    "twitter": {
      "apiKey": "your-twitter-api-key"
    }
  }
}

Disabling

To explicitly disable the connector even when a token is present:

json
{
  "connectors": {
    "twitter": {
      "apiKey": "your-twitter-api-key",
      "enabled": false
    }
  }
}

Setup

After installation, the plugin-auto-enable.ts module checks connectors.twitter in your config. If any of the fields botToken, token, or apiKey is truthy (and enabled is not explicitly false), the runtime automatically loads @elizaos/plugin-x.

No environment variable is required to trigger auto-enable — it is driven entirely by the connector config object. However, the plugin must first be installed via the registry (see Installation above).

Environment Variables

Unlike Discord, Telegram, and Slack, the Eliza runtime does not inject Twitter secrets into process.env via the CHANNEL_ENV_MAP. The plugin reads credentials directly from the connectors.twitter config object.

The plugin also reads these environment variables as a fallback if the corresponding config fields are absent:

VariableConfig Equivalent
TWITTER_API_KEYapiKey
TWITTER_API_SECRET_KEYapiSecretKey
TWITTER_ACCESS_TOKENaccessToken
TWITTER_ACCESS_TOKEN_SECRETaccessTokenSecret
TWITTER_DRY_RUNdryRun
TWITTER_POST_ENABLEpostEnable
TWITTER_POST_INTERVAL_MINpostIntervalMin
TWITTER_POST_INTERVAL_MAXpostIntervalMax
TWITTER_SEARCH_ENABLEsearchEnable
TWITTER_AUTO_RESPOND_MENTIONSautoRespondMentions
TWITTER_POLL_INTERVALpollInterval

Config fields take precedence over environment variables. When using config-based setup, you do not need to set any environment variables.

Full Configuration Reference

All fields are nested under connectors.twitter in eliza.json.

Note: Twitter does not support multi-account configuration. Only a single Twitter account can be configured per agent.

Authentication

FieldTypeDescription
apiKeystringTwitter/X API key (consumer key)
apiSecretKeystringAPI secret key (consumer secret)
accessTokenstringOAuth access token
accessTokenSecretstringOAuth access token secret
enabledbooleanExplicitly enable/disable the connector

Posting Configuration

FieldTypeDefaultDescription
postEnablebooleantrueEnable automated posting
postImmediatelybooleanfalsePost immediately on startup (skip initial delay)
postIntervalMininteger > 090Minimum minutes between automated posts
postIntervalMaxinteger > 0180Maximum minutes between automated posts
postIntervalVariancenumber 0–10.1Randomization factor applied to the interval
maxTweetLengthinteger > 04000Maximum tweet character length

The posting interval is calculated as a random value between postIntervalMin and postIntervalMax, with additional variance applied by the postIntervalVariance factor.

Interaction Settings

FieldTypeDefaultDescription
searchEnablebooleanfalseEnable keyword search monitoring
autoRespondMentionsbooleantrueAutomatically respond to @mentions
enableActionProcessingbooleantrueProcess actions (like, retweet, quote)
timelineAlgorithm"weighted" | "latest""weighted"Timeline processing algorithm
pollIntervalinteger > 0120Seconds between polling for new mentions/interactions

DM Policy

FieldTypeDefaultDescription
dmPolicy"pairing" | "allowlist" | "open" | "disabled""pairing"DM access policy

Safety and Testing

FieldTypeDefaultDescription
dryRunbooleanfalseWhen true, the agent generates posts but does not actually publish them. Useful for testing
retryLimitinteger > 03Max retry attempts for failed API calls
configWritesbooleanAllow config writes from Twitter events

Example: Full Configuration

json
{
  "connectors": {
    "twitter": {
      "apiKey": "your-consumer-key",
      "apiSecretKey": "your-consumer-secret",
      "accessToken": "your-access-token",
      "accessTokenSecret": "your-access-token-secret",
      "postEnable": true,
      "postIntervalMin": 60,
      "postIntervalMax": 120,
      "searchEnable": true,
      "autoRespondMentions": true,
      "timelineAlgorithm": "weighted",
      "dryRun": false
    }
  }
}