Graphrt

X (Twitter)

X posts, replies, likes, reposts, DMs and media upload (X bills per request)

Beta v0.2.0 Node.js 21 actions ToS risk medium
Use in Graphrt Desktop

About

A Graphrt plugin for the official X API v2. It publishes and manages posts, reads mentions and replies, likes and reposts, moderates replies, sends direct messages and uploads images, all as the user who owns the OAuth 2.0 access token. Every operation is a workflow node. Agent tools are limited by the agent policy.

What it can do

  • Users: the authenticated user, lookup by username
  • Posts: create (text, reply, quote, up to 4 media, poll, reply settings), delete, read, list a user's posts, list mentions, recent search (last 7 days)
  • Replies and engagement: list a conversation's replies, hide/unhide replies, like/unlike, repost/undo
  • Direct messages: list DM events, read one conversation, send a DM (text and/or image), start a group DM
  • Media: upload_media downloads an image from an https URL on a public host (up to 5 MB, every redirect hop must stay https and public) and uploads it
  • Tokens: refresh_access_token, which is node only and never offered to agents (X rotates refresh tokens, so the new one is returned)
  • api_request: any other X API v2 endpoint, restricted to api.x.com
  • Retries rate limits using x-rate-limit-reset, and gives clear error kinds. Tokens never appear in errors.

Actions

Each action is a step you can add to a workflow. Agents can also use most of them as tools.

  • Get my X profile x-api.get_me
  • Get X user by username x-api.get_user_by_username
  • Create X post x-api.create_post
  • Delete X post x-api.delete_post
  • Get X post x-api.get_post
  • List X user posts x-api.list_user_posts
  • List X mentions x-api.list_mentions
  • Search recent X posts x-api.search_recent_posts
  • List X replies x-api.list_replies
  • Hide/unhide X reply x-api.hide_reply
Show all 21 actions
  • Like X post x-api.like_post
  • Unlike X post x-api.unlike_post
  • Repost X post x-api.repost
  • Undo X repost x-api.undo_repost
  • List X DM events x-api.list_dm_events
  • List X DM conversation x-api.list_dm_conversation_events
  • Send X DM x-api.send_dm
  • Create X group DM x-api.create_group_dm
  • Upload X image x-api.upload_media
  • Refresh X access token x-api.refresh_access_token
  • X API request x-api.api_request

Settings

Graphrt starts plugins with a clean environment. Only these values reach the plugin, and secrets stay out of logs.

  • X_ACCESS_TOKEN Yes, except for refresh_access_token
    OAuth 2.0 user access token (expires after 2 hours)
  • X_USER_ID Optional
    Your numeric user id. If it's unset, operations that need it (likes, reposts, your posts and mentions) call GET /2/users/me once per run, which is one extra billed user read.
  • X_REFRESH_TOKEN Optional
    Default refresh token for refresh_access_token
  • X_CLIENT_ID Optional
    Default OAuth 2.0 client id for refresh_access_token
  • X_TOOL_ALLOW_POST Optional
    1 lets agent tools publish: create_post (posts, replies, quotes), repost, undo_repost
  • X_TOOL_ALLOW_ENGAGE Optional
    1 lets agent tools like_post, unlike_post and hide_reply
  • X_TOOL_ALLOW_DM Optional
    1 lets agent tools send_dm and create_group_dm, to recipients in X_TOOL_RECIPIENT_ALLOWLIST only
  • X_TOOL_RECIPIENT_ALLOWLIST With X_TOOL_ALLOW_DM
    Comma-separated user ids (and, for send_dm with conversation_id, conversation ids) agent tools may message, matched exactly. Unset refuses every agent DM
  • X_CLIENT_SECRET Optional
    Client secret for confidential apps, used by refresh_access_token (Basic auth). Public PKCE apps leave it unset.
  • X_API_TOOL_TOKEN_SOURCE

How to use it

In Graphrt Desktop

  1. Open Plugins and search for X (Twitter).
  2. Click Install and approve it.
  3. Follow the setup steps on the plugin's page, then paste the settings it needs.
  4. Describe a job that needs it, and the builder adds the steps.
Plugins in Graphrt Desktop

With the CLI

terminal
$ graphrt plugin install x-api
workflow.yaml
- id: image
  type: x-api.upload_media
  image_url: "https://example.com/launch.png"
- id: post
  type: x-api.create_post
  text: "We just launched!"
  media_ids: ["{{#image.data.data.id#}}"]
- id: thanks
  type: x-api.send_dm
  participant_id: "{{#start.user_id#}}"
  text: "Thanks for the feedback!"
Plugins in the docs