Skip to main content

Overview

Webhooks are the communication backbone of Nadoo AI’s multi-channel messaging system. Every incoming message from Slack, Discord, Telegram, KakaoTalk, and other platforms arrives through a webhook endpoint. Outgoing responses are delivered through a managed delivery queue with retry logic and circuit breakers for reliability.

Architecture

Webhook Endpoint

All incoming webhooks are received at a single, channel-type-parameterized endpoint:
POST /api/v1/webhooks/handle/{channel_type}
Channel TypeEndpoint
SlackPOST /api/v1/webhooks/handle/slack
DiscordPOST /api/v1/webhooks/handle/discord
TelegramPOST /api/v1/webhooks/handle/telegram
KakaoTalkPOST /api/v1/webhooks/handle/kakaotalk
Microsoft TeamsPOST /api/v1/webhooks/handle/teams
WhatsAppPOST /api/v1/webhooks/handle/whatsapp
CustomPOST /api/v1/webhooks/handle/custom

Request Processing

When a webhook request arrives:
  1. Route — The {channel_type} parameter determines which adapter handles the request.
  2. Verify — The request signature is validated using the channel’s configured secret.
  3. Parse — The adapter extracts the message content, sender information, and metadata.
  4. Normalize — The platform-specific payload is converted into Nadoo AI’s internal message format.
  5. Process — The normalized message is routed to the configured workflow.
  6. Respond — The workflow output is queued for delivery back to the originating platform.

Webhook Verification Flow

Each platform uses a different mechanism to verify that webhook requests are authentic. Nadoo AI handles all verification automatically.
Method: HMAC-SHA256 signature verification
  1. Slack sends the X-Slack-Signature and X-Slack-Request-Timestamp headers with each request.
  2. Nadoo AI computes HMAC-SHA256(signing_secret, "v0:{timestamp}:{body}").
  3. The computed signature is compared against the header value.
  4. Requests older than 5 minutes are rejected to prevent replay attacks.

Delivery Queue

Outbound messages are not sent directly to platforms. Instead, they are placed in a delivery queue that handles rate limiting, retries, and failure recovery.

Queue Architecture

Priority Levels

Messages in the queue are processed by priority:
PriorityDescriptionExamples
HighError notifications, system alertsWorkflow failure notifications, rate limit warnings
NormalStandard user responsesBot replies to user messages
LowBatch operations, background notificationsScheduled reports, bulk updates

Retry Logic

When a delivery attempt fails, the message is placed in the retry queue with exponential backoff and jitter.
AttemptBase DelayMax DelayDescription
1st retry1 secondImmediate retry for transient network errors
2nd retry2 secondsShort wait
3rd retry4 secondsMedium wait
4th retry8 seconds30 secondsCapped at max delay
5th retry (final)16 seconds30 secondsLast attempt before dead letter queue
Jitter is added to each delay to prevent thundering herd problems when multiple messages are retrying simultaneously.
actual_delay = base_delay * (2 ^ attempt) * (0.5 + random(0, 0.5))
After all retry attempts are exhausted, the message is moved to the Dead Letter Queue for manual inspection and replay.

Configuration

{
  "delivery": {
    "max_retries": 5,
    "base_delay_seconds": 1,
    "max_delay_seconds": 30,
    "jitter": true
  }
}

Circuit Breaker

The circuit breaker prevents the delivery queue from repeatedly sending messages to a platform that is experiencing an outage. This protects both the Nadoo AI backend and the external platform from excessive failed requests.

States

StateBehavior
ClosedNormal operation. Messages are delivered to the platform. Errors are counted.
OpenThe platform is considered unhealthy. Messages are routed to the dead letter queue instead of being sent. No delivery attempts are made.
Half-OpenAfter a recovery timeout, a single probe message is sent to test if the platform has recovered. If successful, the circuit closes. If the probe fails, the circuit reopens.

Configuration

{
  "circuit_breaker": {
    "error_threshold": 5,
    "error_window_seconds": 60,
    "recovery_timeout_seconds": 30,
    "probe_interval_seconds": 10
  }
}
ParameterDefaultDescription
error_threshold5Number of consecutive errors before the circuit opens
error_window_seconds60Time window for counting errors
recovery_timeout_seconds30Time to wait before sending a probe in the half-open state
probe_interval_seconds10Interval between probe attempts in the half-open state

Status Monitoring

Monitor the health and delivery status of your webhooks through the monitoring API.

Webhook Status

curl -X GET \
  "https://your-instance.example.com/api/v1/webhooks/status/{webhook_id}" \
  -H "Authorization: Bearer YOUR_API_KEY"
Response:
{
  "webhook_id": "wh_abc123",
  "channel_type": "slack",
  "status": "active",
  "circuit_breaker_state": "closed",
  "stats": {
    "messages_delivered": 1542,
    "messages_failed": 3,
    "messages_in_queue": 0,
    "messages_in_dead_letter": 1,
    "avg_delivery_time_ms": 245,
    "last_delivery_at": "2026-03-09T10:30:00Z",
    "last_error_at": "2026-03-08T14:22:00Z",
    "last_error_message": "Rate limit exceeded (429)"
  },
  "rate_limit": {
    "requests_per_second": 1,
    "current_usage": 0.3
  }
}

List All Webhooks

curl -X GET \
  "https://your-instance.example.com/api/v1/webhooks/status" \
  -H "Authorization: Bearer YOUR_API_KEY"

Dead Letter Queue

Inspect and replay messages that failed all delivery attempts. List dead letter messages:
curl -X GET \
  "https://your-instance.example.com/api/v1/webhooks/{webhook_id}/dead-letters" \
  -H "Authorization: Bearer YOUR_API_KEY"
Replay a dead letter message:
curl -X POST \
  "https://your-instance.example.com/api/v1/webhooks/{webhook_id}/dead-letters/{message_id}/replay" \
  -H "Authorization: Bearer YOUR_API_KEY"
Replay all dead letters for a webhook:
curl -X POST \
  "https://your-instance.example.com/api/v1/webhooks/{webhook_id}/dead-letters/replay-all" \
  -H "Authorization: Bearer YOUR_API_KEY"

Best Practices

All webhook endpoints must be served over HTTPS with a valid SSL/TLS certificate. Self-signed certificates are not accepted by most messaging platforms. Use Let’s Encrypt for free certificates or your organization’s certificate authority.
Set up alerts for when a circuit breaker transitions to the Open state. This indicates a platform outage or configuration issue that needs attention. The status monitoring API provides the current state for each webhook.
Messages in the dead letter queue represent failed communications. Review them regularly to identify patterns (e.g., recurring errors for a specific channel) and replay messages after resolving the underlying issue.
Each platform has its own rate limits. Nadoo AI’s delivery queue respects these automatically, but you can configure additional application-level rate limits to stay well below platform quotas during peak traffic.
Store signing secrets, bot tokens, and API keys in the Nadoo AI platform’s encrypted credential store. Do not hard-code secrets in configuration files or expose them in logs.

Next Steps