Webhook
Webhooks
WhatsApp Webhook
Handle incoming WhatsApp webhooks.
This endpoint processes incoming WhatsApp messages and events,
providing fast responses for text messages and background processing
for heavy operations.
Features:
- Fast text responses (2-4 seconds)
- Background processing for heavy operations
- No external caching dependencies
- Duplicate message detection
- Language preference support
Args:
payload: WhatsApp webhook payload.
background_tasks: FastAPI background tasks for async processing.
Returns:
WebhookResponse with processing status and time.
Response Status Codes:
- 200: Successfully processed
- 400: Invalid payload format
- 500: Internal server error
Example Payload:
{
"entry": [{
"changes": [{
"value": {
"messages": [{
"from": "1234567890",
"text": {"body": "Hello"}
}],
"contacts": [{
"profile": {"name": "John"}
}],
"metadata": {
"phone_number_id": "9876543210"
}
}
}]
}]
}
Example Response:
{
"status": "success",
"processing_time": 2.5
}
POST
Webhook
Body
application/json
The body is of type Payload · object.
Response
Successful Response
Response model for webhook handling.
Attributes: status: Status of the webhook processing. processing_time: Time taken to process the webhook (optional). message: Additional information about the processing (optional).
Example: { "status": "success", "processing_time": 2.5 }

