Webhooks
Webhooks allow you to receive real-time notifications when events happen in your WhatsApp account.
Setting up a Webhook
- Navigate to the Webhooks page.
- Switch the toggle to "Active" globally to enable processing.
- Click Add Webhook.
- Name: Give your webhook a descriptive name.
- URL: The valid HTTPS endpoint where WhatsSpot will send POST requests.
- Toggle Active: Turn on "Active" to start receiving events immediately.
Supported Events
WhatsSpot currently supports the following events:
| Event Name | Description |
|---|---|
message.received | Triggered when a new message arrives. |
message.ack | Triggered when a message status changes (sent, delivered, read). |
device.disconnected | Triggered when a WhatsApp session is logged out. |
Payload Examples
1. Message Received
{
"event": "message.received",
"data": {
"id": "false_1234567890@c.us_3EB0...",
"from": "1234567890",
"to": "YOUR_DEVICE_NUMBER",
"body": "Hello world",
"type": "chat",
"timestamp": 1678900000,
"hasMedia": false
}
}
2. Message Status Update (Ack)
{
"event": "message.ack",
"data": {
"id": "false_1234567890@c.us_3EB0...",
"status": "READ", // SENT, DELIVERED, READ
"ack": 3
}
}
Security & Verification
To ensure requests are coming from WhatsSpot, we include a X-Hub-Signature header if you configured a secret.
// Node.js Example to verify signature
const crypto = require('crypto');
const signature = req.headers['x-hub-signature'];
const expected = crypto.createHmac('sha256', YOUR_SECRET).update(JSON.stringify(req.body)).digest('hex');
if (signature === expected) {
// Verified!
}