mcpField
W
webflow-webhooks

webflow-webhooks

github.com/hookdeck開発95190 回インストール今日更新
リポジトリ

webflow-webhooks について

webflow-webhooks は、Webflow Webhook の受信、署名検証、イベント処理の実装を案内するスキルです。Webflow のフォーム、E コマース、公開、CMS イベントを扱う開発者向けに、署名検証の前提条件とローカルテスト方法も説明します。

主な機能

  1. 01Webhook 署名検証のガイド
  2. 02リプレイ防止のタイムスタンプ検証
  3. 03一般的な Webflow イベントの説明
  4. 04生のリクエストボディの処理例
  5. 05Hookdeck CLI によるローカルテスト

活用シーン

  1. 01署名付き Webflow Webhook リクエストの検証
  2. 02フォーム送信や注文の処理
  3. 03CMS アイテム変更時のシステム更新
  4. 04ローカル開発での Webhook 配信テスト

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hookdeck/webhook-skills --skill webflow-webhooks

インストール後、Claude Code で/webflow-webhooksを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

examples/express/
.env.example
package.json
README.md
examples/express/src/
index.js
examples/express/test/
webhook.test.js
examples/fastapi/
.env.example
main.py
README.md
requirements.txt
test_webhook.py
examples/nextjs/
.env.example
package.json
README.md
vitest.config.ts
examples/nextjs/app/webhooks/webflow/
route.ts
examples/nextjs/test/
webhook.test.ts
references/
overview.md
setup.md
verification.md

詳細

Webflow Webhooks

このスキルを使用する場面

  • Webflow の Webhook を受信するにはどうすればよいですか?
  • Webflow の Webhook 署名を検証するにはどうすればよいですか?
  • Webflow の form_submission イベントを処理するにはどうすればよいですか?
  • Webflow の eコマース注文イベントを処理するにはどうすればよいですか?
  • Webflow の Webhook 署名検証に失敗するのはなぜですか?
  • Webflow CMS コレクションアイテムの Webhook を設定する

必須コード

署名検証(手動)
const crypto = require('crypto');

function verifyWebflowSignature(rawBody, signature, timestamp, secret) {
  // Check timestamp to prevent replay attacks (5 minute window - 300000 milliseconds)
  const currentTime = Date.now();
  if (Math.abs(currentTime - parseInt(timestamp)) > 300000) {
    return false;
  }

  // Generate HMAC signature
  const signedContent = `${timestamp}:${rawBody}`;
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(signedContent)
    .digest('hex');

  // Timing-safe comparison
  try {
    return crypto.timingSafeEqual(
      Buffer.from(signature),
      Buffer.from(expectedSignature)
    );
  } catch {
    return false; // Different lengths = invalid
  }
}
イベントの処理
app.post('/webhooks/webflow', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.headers['x-webflow-signature'];
  const timestamp = req.headers['x-webflow-timestamp'];

  if (!signature || !timestamp) {
    return res.status(400).send('Missing required headers');
  }

  // Verify signature (use OAuth client secret or webhook-specific secret)
  const isValid = verifyWebflowSignature(
    req.body.toString(),
    signature,
    timestamp,
    process.env.WEBFLOW_WEBHOOK_SECRET
  );

  if (!isValid) {
    return res.status(400).send('Invalid signature');
  }

  // Parse the verified payload
  const event = JSON.parse(req.body);

  // Handle different event types
  switch (event.triggerType) {
    case 'form_submission':
      console.log('New form submission:', event.payload.data);
      break;
    case 'ecomm_new_order':
      console.log('New order:', event.payload);
      break;
    case 'collection_item_created':
      console.log('New CMS item:', event.payload);
      break;
    // Add more event handlers as needed
  }

  // Always return 200 to acknowledge receipt
  res.status(200).send('OK');
});

一般的なイベントタイプ

イベント発生条件使用例
form_submissionサイトでフォームが送信されたとき問い合わせフォーム、リードの獲得
site_publishサイトが公開されたときキャッシュのクリア、ビルドの開始
ecomm_new_order新しい eコマース注文があったとき注文処理、在庫管理
ecomm_order_changed注文ステータスが変更されたときフルフィルメントシステムの更新
collection_item_createdCMS アイテムが作成されたときコンテンツのシンジケーション
collection_item_changedCMS アイテムが更新されたとき外部システムの更新
collection_item_deletedCMS アイテムが削除されたとき外部システムからの削除
collection_item_publishedCMS アイテムが公開されたときキャッシュの無効化、後続システムへの公開

Webflow は All Events に 13 種類のイベントを記載しています。公式の webflow-api SDK の TriggerType enum には、それらに加えて collection_item_published が含まれています。user_account_* イベントは非推奨です。詳しくは references/overview.md をご覧ください。

環境変数

# For webhooks created via OAuth App
WEBFLOW_WEBHOOK_SECRET=your_oauth_client_secret

# For webhooks created via API (after April 2025)
WEBFLOW_WEBHOOK_SECRET=whsec_xxxxx  # Returned when creating webhook

ローカル開発

ローカルで Webhook をテストするには、Hookdeck CLI をインストールします。

次に、トンネルを起動します。

npx hookdeck-cli listen 3000 webflow --path /webhooks/webflow

アカウントは不要です。ローカルトンネルと、リクエストを確認するための Web UI が利用できます。

リソース

重要な注意事項

  • Webflow ダッシュボードから作成した Webhook には、署名ヘッダーが含まれません
  • OAuth アプリまたは API 経由で作成した Webhook のみ、x-webflow-signature と x-webflow-timestamp が含まれます
  • 署名検証には、解析済みの JSON ではなく、必ず生のボディを使用してください
  • リプレイ攻撃を防ぐには、タイムスタンプの検証(5 分間、つまり 300000 ミリ秒)が重要です
  • 受信を確認するために 200 ステータスを返してください。それ以外のステータスでは再試行されます(最大 3 回)

推奨:webhook-handler-patterns

本スキルは、production-ready な実装に向けて webhook-handler-patterns と併用できます。

関連スキル

出典:

コメント