Command Palette

Search for a command to run...

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

messenger-webhooks

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

Receive and verify Facebook Messenger Platform webhooks. Use when setting up Messenger webhook handlers for a Facebook Page, completing the GET hub.challenge…

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

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

Facebook Messenger Webhooks

Messenger Platform webhooks use the Meta webhook mechanism: a GET handshake when you save the Callback URL, then POST deliveries signed with X-Hub-Signature-256. They do not follow the Standard Webhooks spec. The body is { "object": "page", "entry": [...] }, and each entry carries a messaging[] array (or standby[] under the handover protocol).

Instagram DMs built on the Messenger Platform arrive with object: "instagram"; see instagram-webhooks. Page feed and other Page changes[] webhooks are covered by facebook-webhooks.

When to Use This Skill

  • How do I receive Facebook Messenger webhooks?
  • How do I verify Messenger webhook signatures with X-Hub-Signature-256?
  • How do I complete the Messenger hub.challenge verification handshake?
  • Why does Messenger signature verification fail for messages with emoji or accents?
  • How do I handle messages, messaging_postbacks, message_reads or message_deliveries events?

Two Requests, Two Jobs

  1. GET: handshake. Meta sends hub.mode=subscribe, hub.verify_token and hub.challenge. If the token matches the Verify Token you set in the App Dashboard, reply 200 with the raw hub.challenge.
  2. POST: event delivery. A JSON body signed with X-Hub-Signature-256. Reply 200 within 5 seconds.

Verification (core)

Meta sends X-Hub-Signature-256: sha256=<hex>, the HMAC-SHA256 hex digest of the request body keyed with your App Secret (App settings > Basic). Meta signs an escaped-unicode form of the payload (äöå as \u00e4\u00f6\u00e5), so verify over the raw bytes exactly as received; re-serialising parsed JSON produces different bytes. Require the sha256= prefix, check the digest is 64 hex characters, compare in constant time.

Node:

const crypto = require('crypto');

function verify(rawBody, signatureHeader, appSecret) {
  const match = /^sha256=([0-9a-f]{64})$/i.exec(signatureHeader || '');
  if (!match || !appSecret) return false;
  const received = Buffer.from(match[1], 'hex'); // safe: regex guarantees 64 hex chars
  const expected = crypto.createHmac('sha256', appSecret).update(rawBody).digest();
  return received.length === expected.length && crypto.timingSafeEqual(received, expected);
}

Python:

import hmac, hashlib, re

def verify(raw_body: bytes, signature_header: str, app_secret: str) -> bool:
    match = re.fullmatch(r"sha256=([0-9a-fA-F]{64})", signature_header or "")
    if not match or not app_secret:
        return False
    expected = hmac.new(app_secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(match.group(1).lower().encode(), expected.encode())

In Express, read the body with express.raw({ type: '*/*' }) so every content type reaches the verifier as unparsed bytes.

For complete handlers with the GET handshake, event dispatch, and tests, see:

Common Event Types

The payload doesn't name the field you subscribed to: each messaging[] item has sender, recipient, timestamp and one event key.

Subscribed field Key on the item Triggered when
messages message (mid, text, attachments, quick_reply, reply_to) A person sends the Page a message
message_echoes message with is_echo: true, app_id, metadata The Page sends a message
messaging_postbacks postback (title, payload, mid, optional referral) A postback button, Get Started or persistent menu item is tapped
message_reads read (watermark) The person reads Page messages up to watermark
message_deliveries delivery (watermark, optional mids) Page messages are delivered
message_reactions reaction (reaction, emoji, action, mid) A person reacts or unreacts
messaging_optins optin (type: notification_messages, notification_messages_token, ...) A person opts in to Marketing Messages or taps Send to Messenger
messaging_referrals referral (ref, source: SHORTLINK/ADS, type) A person with an existing thread opens an m.me link or ad
message_edits message_edit (mid, text, num_edit) A person edits a message
messaging_account_linking account_linking (status, authorization_code) Link/Unlink Account is tapped
{
  "object": "page",
  "entry": [
    {
      "id": "<PAGE_ID>",
      "time": 1458692752478,
      "messaging": [
        {
          "sender": { "id": "<PSID>" },
          "recipient": { "id": "<PAGE_ID>" },
          "timestamp": 1458692752478,
          "message": { "mid":
Полный SKILL.md на GitHub

Установить messenger-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/messenger/route.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

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

Receive and verify Facebook Messenger Platform webhooks. Use when setting up Messenger webhook handlers for a Facebook Page, completing the GET hub.challenge handshake, debugging X-Hub-Signature-256 signature verification (escaped-unicode raw body), or handling messages, messaging_postbacks, message_reads, message_deliveries, message_reactions, messaging_optins, messaging_referrals, and message_echoes events.

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

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

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

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

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

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