Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

twitter-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and verify X (Twitter) webhooks from the X Activity API and the Account Activity API. Use when setting up X webhook handlers, answering the CRC…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

Twitter / X Webhooks

X delivers activity to a webhook you register with the V2 Webhooks API (POST /2/webhooks). Two products deliver to it:

  • X Activity API (XAA), the current product: one subscription per event type and user, each event wrapped in a data envelope with data.event_type.
  • Account Activity API (AAA): one all-activity subscription per user, payloads keyed by activity (tweet_create_events, ...). X says AAA reaches end of life on February 28, 2027.

Your public HTTPS endpoint must do two things:

  1. Answer the CRC (Challenge-Response Check). X sends a GET with a crc_token query parameter when the webhook is created, on PUT /2/webhooks/:webhook_id, and periodically. Reply with a JSON response_token, or X marks the webhook invalid and stops delivering.
  2. Verify POST deliveries against the signature header before processing.

Both use the same primitive: sha256= + base64(HMAC-SHA256(secret, message)). The secret is your app's OAuth 2.0 client secret (recommended), or its OAuth 1.0 consumer secret (API Secret Key) for an app that only has that. Never the bearer token or a user access token.

When to Use This Skill

  • How do I receive X (Twitter) webhooks?
  • How do I respond to the X CRC / crc_token challenge?
  • How do I verify X-Twitter-Webhooks-Signature-OAuth2 or X-Twitter-Webhooks-Signature?
  • How do I handle post.create, like.create or dm.received events?
  • How do I handle both Account Activity API and X Activity API payloads during migration?
  • Why is my X webhook marked invalid / why did delivery stop?

Verification (core)

Header Keyed with
X-Twitter-Webhooks-Signature-OAuth2 OAuth 2.0 client secret (recommended)
X-Twitter-Webhooks-Signature OAuth 1.0 consumer secret (legacy)

An app with only a client secret receives only the OAuth2 header; one with only a consumer secret receives only the legacy header; one with both may receive both. Accept a match on any header you hold the secret for:

const crypto = require('crypto');

// sha256= + base64(HMAC-SHA256(secret, message))
function buildSignature(message, secret) {
  return 'sha256=' + crypto.createHmac('sha256', secret).update(message).digest('base64');
}

function safeEqual(a, b) {
  const left = Buffer.from(a);
  const right = Buffer.from(b);
  return left.length === right.length && crypto.timingSafeEqual(left, right);
}

// CRC GET: reply { response_token: buildSignature(crc_token, clientSecret || consumerSecret) }
// POST: compare against the raw body, never re-serialised JSON
function verifyTwitterSignature(rawBody, headers, { clientSecret, consumerSecret }) {
  return [
    [headers['x-twitter-webhooks-signature-oauth2'], clientSecret],
    [headers['x-twitter-webhooks-signature'], consumerSecret],
  ].some(([sig, secret]) => typeof sig === 'string' && !!secret && safeEqual(sig, buildSignature(rawBody, secret)));
}

Note: X's signature has no timestamp, and X publishes no retry schedule. X says an event can arrive more than once, so deduplicate and make handlers idempotent. Return 200 within 10 seconds.

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

Telling Events Apart

X's migration guide: AAA payloads have a top-level for_user_id, and XAA payloads have a top-level data.event_type. Route on whichever is present.

XAA data.event_type Fires when AAA payload key
post.create The subscribed user posts, replies, quotes or reposts tweet_create_events
post.mention.create / post.reply.create Another account mentions or replies to the user tweet_create_events
post.delete The user deletes a Post tweet_delete_events
like.create The user likes a Post, or one of theirs is liked favorite_events
follow.follow / follow.unfollow A follow or unfollow by or of the user follow_events (type is follow / unfollow)
dm.received / dm.sent An unencrypted DM is received or sent direct_message_events
oauth.revoke A user revokes your app (no subscription needed) user_event

XAA also has profile updates, encrypted XChat (chat.*), mutes, blocks, Spaces, broadcasts, paid subscriptions and news.new.

For the full event reference, see references/overview.md and X's event payloads.

Environment Variables

# OAuth 2.0 Client Secret (X Developer Console -> your App -> Keys and tokens)
TWITTER_CLIENT_SECRET=your_client_secret_here
# Optional, legacy: OAuth 1.0 consumer secret (API Secret Key)
TWITTER_CONSUMER_SECRET=

Local Development

X's xurl tool can open a temporary webhoo

Полный SKILL.md на GitHub

Установить twitter-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/twitter/route.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл twitter-webhooks?

Receive and verify X (Twitter) webhooks from the X Activity API and the Account Activity API. Use when setting up X webhook handlers, answering the CRC (Challenge-Response Check) crc_token request, debugging the X-Twitter-Webhooks-Signature-OAuth2 or X-Twitter-Webhooks-Signature HMAC-SHA256 check, or handling events like post.create, like.create, follow.follow, dm.received, tweet_create_events and direct_message_events.

Как установить скилл twitter-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл twitter-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить twitter-webhooks с