Integrations & API
Receiving messages via webhooks
5 minutes read time Difficulty: intermediate
Receiving messages via webhooks
Webhooks send real-time HTTP notifications to your server when events happen in AIsoule.
What are webhooks?
Instead of polling the API repeatedly, webhooks push data to your server instantly when:
- A new message arrives
- A message is delivered or read
- A contact is created or updated
- A campaign completes
- An agent transfer happens
Setting up a webhook
- Go to Settings → Webhooks
- Click "New Webhook"
- Configure:
- Name — Descriptive name (e.g., "CRM Sync")
- URL — Your server endpoint (must be HTTPS)
- Events — Select which events to receive
- Secret — Auto-generated HMAC secret for verification
- Click Save
Available events
| Event | Triggered when |
|---|---|
message.incoming | New message received from customer |
message.sent | Message sent successfully |
message.delivered | Message delivered to recipient |
message.read | Message read by recipient |
message.failed | Message delivery failed |
contact.created | New contact added |
contact.updated | Contact data changed |
campaign.completed | Campaign finished sending |
transfer.created | Agent transfer initiated |
Webhook payload format
{
"event": "message.incoming",
"timestamp": "2026-05-29T10:30:00Z",
"data": {
"message_id": "wamid.xxx",
"from": "+919876543210",
"contact_name": "John Doe",
"type": "text",
"text": "Hello, I need help with my order",
"whatsapp_account_id": "uuid"
}
}
Verifying webhook signatures
Every webhook request includes an HMAC-SHA256 signature in the X-Webhook-Signature header.
To verify:
- Get the raw request body
- Compute HMAC-SHA256 using your webhook secret
- Compare with the
X-Webhook-Signatureheader
import hmac, hashlib
def verify_signature(body, signature, secret):
expected = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
Requirements for your endpoint
- Must respond with HTTP 200 within 5 seconds
- Must accept POST requests
- Must use HTTPS (HTTP not supported)
- Should be idempotent (same event may be sent twice)
Retry policy
If your endpoint doesn't respond with 200:
- AIsoule retries 3 times with exponential backoff
- Delays: 10 seconds, 60 seconds, 5 minutes
- After 3 failures, the webhook is marked as failing
Testing webhooks
Use tools like webhook.site or ngrok to test locally:
- Get a temporary HTTPS URL from webhook.site
- Set it as your webhook URL in AIsoule
- Send a test message to your WhatsApp number
- See the webhook payload arrive in real-time
Tips
- Respond quickly — Process asynchronously, respond 200 immediately
- Handle duplicates — Use message_id to deduplicate
- Monitor failures — Check webhook status in Settings → Webhooks
- Use the secret — Always verify signatures in production
- Log everything — Store raw payloads for debugging
Related Articles
Was this guide helpful?
Your feedback helps us make these guides better for everyone.