instantly-webhooks-events
Instantlyのウェブフック署名検証とイベントハンドリングを実装できます。ウェブフックエンドポイントの設定、署名検証の実装、またはInstantlyのイベント通知を安全に処理する際に利用します。「instantly webhook」「instantly events」「instantly webhook signature」「handle instantly events」「instantly notifications」などのフレーズで起動します。
description の原文を見る
Implement Instantly webhook signature validation and event handling. Use when setting up webhook endpoints, implementing signature verification, or handling Instantly event notifications securely. Trigger with phrases like "instantly webhook", "instantly events", "instantly webhook signature", "handle instantly events", "instantly notifications".
SKILL.md 本文
Instantlyウェブフック&イベント
概要
署名検証とリプレイ保護を使用して、Instantlyウェブフックを安全に処理します。
前提条件
- Instantlyウェブフックシークレットが設定されていること
- インターネットからアクセス可能なHTTPSエンドポイント
- 暗号署名の理解
- アイデンポテンシー用のRedisまたはデータベース(オプション)
ウェブフックエンドポイントのセットアップ
Express.js
import express from 'express';
import crypto from 'crypto';
const app = express();
// IMPORTANT: Raw body needed for signature verification
app.post('/webhooks/instantly',
express.raw({ type: 'application/json' }),
async (req, res) => {
const signature = req.headers['x-instantly-signature'] as string;
const timestamp = req.headers['x-instantly-timestamp'] as string;
if (!verifyInstantlySignature(req.body, signature, timestamp)) {
return res.status(401).json({ error: 'Invalid signature' });
}
const event = JSON.parse(req.body.toString());
await handleInstantlyEvent(event);
res.status(200).json({ received: true });
}
);
署名検証
function verifyInstantlySignature(
payload: Buffer,
signature: string,
timestamp: string
): boolean {
const secret = process.env.INSTANTLY_WEBHOOK_SECRET!;
// Reject old timestamps (replay attack protection)
const timestampAge = Date.now() - parseInt(timestamp) * 1000;
if (timestampAge > 300000) { // 5 minutes
console.error('Webhook timestamp too old');
return false;
}
// Compute expected signature
const signedPayload = `${timestamp}.${payload.toString()}`;
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
// Timing-safe comparison
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expectedSignature)
);
}
イベントハンドラーパターン
type InstantlyEventType = 'resource.created' | 'resource.updated' | 'resource.deleted';
interface InstantlyEvent {
id: string;
type: InstantlyEventType;
data: Record<string, any>;
created: string;
}
const eventHandlers: Record<InstantlyEventType, (data: any) => Promise<void>> = {
'resource.created': async (data) => { /* handle */ },
'resource.updated': async (data) => { /* handle */ },
'resource.deleted': async (data) => { /* handle */ }
};
async function handleInstantlyEvent(event: InstantlyEvent): Promise<void> {
const handler = eventHandlers[event.type];
if (!handler) {
console.log(`Unhandled event type: ${event.type}`);
return;
}
try {
await handler(event.data);
console.log(`Processed ${event.type}: ${event.id}`);
} catch (error) {
console.error(`Failed to process ${event.type}: ${event.id}`, error);
throw error; // Rethrow to trigger retry
}
}
アイデンポテンシー処理
import { Redis } from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
async function isEventProcessed(eventId: string): Promise<boolean> {
const key = `instantly:event:${eventId}`;
const exists = await redis.exists(key);
return exists === 1;
}
async function markEventProcessed(eventId: string): Promise<void> {
const key = `instantly:event:${eventId}`;
await redis.set(key, '1', 'EX', 86400 * 7); // 7 days TTL
}
ウェブフックテスト
# Use Instantly CLI to send test events
instantly webhooks trigger resource.created --url http://localhost:3000/webhooks/instantly
# Or use webhook.site for debugging
curl -X POST https://webhook.site/your-uuid \
-H "Content-Type: application/json" \
-d '{"type": "resource.created", "data": {}}'
手順
ステップ 1: ウェブフックエンドポイントの登録
InstantlyダッシュボードでウェブフックURLを設定します。
ステップ 2: 署名検証の実装
署名検証コードを使用して、受け取るウェブフックを検証します。
ステップ 3: イベントの処理
アプリケーションが必要とする各イベントタイプのハンドラーを実装します。
ステップ 4: アイデンポテンシーの追加
イベントIDトラッキングで重複処理を防止します。
出力
- セキュアなウェブフックエンドポイント
- 署名検証が有効
- イベントハンドラーが実装済み
- リプレイ攻撃保護がアクティブ
エラー処理
| 問題 | 原因 | 解決策 |
|---|---|---|
| 無効な署名 | シークレットが間違っている | ウェブフックシークレットを確認してください |
| タイムスタンプが拒否される | クロックドリフト | サーバー時刻の同期を確認してください |
| 重複イベント | アイデンポテンシーがない | イベントIDトラッキングを実装してください |
| ハンドラータイムアウト | 処理が遅い | 非同期キューを使用してください |
例
ローカルでのウェブフックテスト
# Use ngrok to expose local server
ngrok http 3000
# Send test webhook
curl -X POST https://your-ngrok-url/webhooks/instantly \
-H "Content-Type: application/json" \
-d '{"type": "test", "data": {}}'
リソース
次のステップ
パフォーマンス最適化については、instantly-performance-tuningを参照してください。
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- Brmbobo
- リポジトリ
- Brmbobo/Web2podcast
- ライセンス
- MIT
- 最終更新
- 2026/1/26
Source: https://github.com/Brmbobo/Web2podcast / ライセンス: MIT
関連スキル
doubt-driven-development
重要な判断はすべて、本番環境への展開前に新しい視点から対抗的レビューを実施します。速度より正確性が重要な場合、不慣れなコードを扱う場合、本番環境・セキュリティに関わるロジック・取り消し不可の操作など影響度が高い場合、または後でバグを修正するよりも今検証する方が効率的な場合に活用してください。
apprun-skills
TypeScriptを使用したAppRunアプリケーションのMVU設計に関する総合的なガイダンスが得られます。コンポーネントパターン、イベントハンドリング、状態管理(非同期ジェネレータを含む)、パラメータと保護機能を備えたルーティング・ナビゲーション、vistestを使用したテストに対応しています。AppRunコンポーネントの設計・レビュー、ルートの配線、状態フローの管理、AppRunテストの作成時に活用してください。
desloppify
コードベースのヘルスチェックと技術負債の追跡ツールです。コード品質、技術負債、デッドコード、大規模ファイル、ゴッドクラス、重複関数、コードスメル、命名規則の問題、インポートサイクル、結合度の問題についてユーザーが質問した場合に使用してください。また、ヘルススコアの確認、次の改善項目の提案、クリーンアップ計画の作成をリクエストされた際にも対応します。29言語に対応しています。
debugging-and-error-recovery
テストが失敗したり、ビルドが壊れたり、動作が期待と異なったり、予期しないエラーが発生したりした場合に、体系的な根本原因デバッグをガイドします。推測ではなく、根本原因を見つけて修正するための体系的なアプローチが必要な場合に使用してください。
test-driven-development
テスト駆動開発により実装を進めます。ロジックの実装、バグの修正、動作の変更など、あらゆる場面で活用できます。コードが正常に動作することを証明する必要がある場合、バグ報告を受けた場合、既存機能を修正する予定がある場合に使用してください。
incremental-implementation
変更を段階的に実施します。複数のファイルに影響する機能や変更を実装する場合に使用してください。大量のコードを一度に書こうとしている場合や、タスクが一度では完結できないほど大きい場合に活用します。