Deployment & Infrastructure

Webhook

Last updated: February 16, 2026

A webhook is an HTTP callback that delivers real-time event notifications from one service to another. Instead of your application repeatedly polling an external API to check for new data, the external service pushes updates to a URL you specify whenever a relevant event occurs.

Why It Matters

Webhooks are the backbone of real-time integrations for AI assistants. When a user sends a message on Telegram, Discord, Slack, or WhatsApp, the messaging platform delivers that message to your AI gateway via a webhook. Without webhooks, your assistant would need to constantly poll each platform for new messages, wasting resources and introducing latency measured in seconds rather than milliseconds.

How It Works

The webhook lifecycle follows three steps. First, you register a callback URL with the external service, often providing an authentication secret for verification. Second, when an event occurs, the service sends an HTTP POST request to your URL with a JSON payload describing the event. Third, your server processes the payload and returns a response, typically a 200 status code to acknowledge receipt.

Security is essential when handling webhooks. Always verify the request signature or shared secret to confirm the payload genuinely originated from the expected service. Use HTTPS endpoints to protect data in transit, and implement idempotency to handle duplicate deliveries gracefully.

In Practice

When deploying an AI assistant, your public URL must be reachable from the internet for webhook delivery. Platforms like Railway assign public domains automatically. During setup, your gateway registers webhook URLs with each messaging channel. If your domain changes, you must re-register the webhooks. Consider implementing a queue or retry mechanism to handle temporary processing failures without losing incoming messages.