Skip to main content
The gateway is a Bun HTTP server (Bun.serve) defined in packages/core/src/gateway/server.ts. It normalizes incoming webhooks from five sources into a unified Signal format stored in the signals table for the Forge to process.

Endpoints

WhatsApp also handles GET /hooks/whatsapp for the webhook verification challenge.

Signature Verification

Discord

Discord uses Ed25519 signatures verified with the Web Crypto API:
Key is read from GRIND_DISCORD_PUBLIC_KEY. Requests failing verification return 401.

WhatsApp Cloud API

WhatsApp signs payloads with HMAC-SHA256 using the app secret:

Telegram

Telegram does not sign individual payloads. The bot token in the webhook URL path acts as the secret.

Signal Normalization

gateway/normalize.ts converts each platform’s payload into a unified Signal:
Signals are stored to the signals table and consumed by the Forge daemon on its next tick.

Configuration

See Environment Reference for the complete list including webhook paths and host binding.

Adding a New Webhook Source

  1. Add a new endpoint case in gateway/server.ts
  2. Implement signature verification if required
  3. Add a normalizer in gateway/normalize.ts
  4. Handle the new signal type in forge/engine.ts