Duyetbot Agent
Guides

Webhook Endpoint

POST /webhook - GitHub/Telegram events. HMAC sig auth, raw body parse. Returns 200 OK fast.

TL;DR: POST /webhook handles platform events. Verify sig -> parse -> queue. Always 200 <6ms.

Table of Contents

Request

POST /webhook
Content-Type: application/json

Body: Platform payload (GitHub event/Telegram update).

Headers

HeaderRequiredDescExample
X-Hub-Signature-256GitHubHMAC-SHA256 sigsha256=6931...
X-GitHub-EventGitHubEvent typeissue_comment
X-Telegram-Bot-Api-Secret-TokenTelegramBot token12345:ABC...

Responses

StatusBodyMeaning
200"OK"Accepted
401{error: "Invalid signature"}Auth fail

Errors

CodeStatusDesc
INVALID_SIG401HMAC mismatch
MISSING_SIG401No sig header
AUTH_001403Telegram user not allowed

From signature.ts

export function verifySignature(payload: string, signature: string, secret: string): boolean {
  const hmac = createHmac('sha256', secret);
  const digest = `sha256=${hmac.update(payload).digest('hex')}`;
  return timingSafeEqual(Buffer.from(digest), Buffer.from(signature));
}

Telegram auth auth.ts

if (!isUserAuthorized(env, userId)) {
  c.set('unauthorized', true);
}

Quiz: Sig fail -> ? A: 401 + log warn ✅

Integrate

app.post('/webhook', signatureMiddleware, parser, auth, agentHandler);

Deploy: bun run deploy:github -> GitHub webhook -> Test sig!

Related: Deployment | Health ->

On this page