Overview
The SMS webhook endpoint receives delivery reports and incoming SMS messages from Africa’s Talking. This is essential for tracking message delivery status and handling user responses to contract confirmations.Endpoint
Webhook Payload
Africa’s Talking sends webhook data as form-encoded data with the following fields:Incoming SMS Fields
| Field | Type | Description |
|---|---|---|
from | string | Phone number of the sender |
to | string | Your shortcode or phone number |
text | string | Content of the SMS message |
date | string | Timestamp of the message |
id | string | Unique message ID |
linkId | string | Link ID for session-based messages |
Delivery Report Fields
| Field | Type | Description |
|---|---|---|
id | string | Message ID |
status | string | Delivery status (Success, Failed, etc.) |
phoneNumber | string | Recipient phone number |
networkCode | string | Mobile network code |
retryCount | number | Number of retry attempts |
failureReason | string | Reason for failure (if applicable) |
Example Payloads
Incoming SMS Message
Delivery Report
Implementation
The webhook handler processes incoming messages and identifies contract-related responses:Contract Response Format
VoicePact uses a specific format for SMS-based contract responses:- Confirmation:
YES-{contract_id}(e.g.,YES-AG-2024-001) - Rejection:
NO-{contract_id}(e.g.,NO-AG-2024-001)
- Parses the action (YES/NO) and contract ID
- Logs the response
- Updates the contract status in the database
- Sends confirmation SMS to both parties
Security Considerations
Webhook Signature Verification
Verify webhook authenticity using HMAC signature validation:Best Practices
- IP Whitelisting: Restrict webhook endpoint to Africa’s Talking IP addresses
- HTTPS Only: Always use HTTPS for webhook URLs
- Idempotency: Handle duplicate webhooks gracefully using message IDs
- Timeout Handling: Respond quickly (within 10 seconds) to avoid retries
- Error Logging: Log all webhook data for debugging and audit trails
Configuring the Webhook URL
Set your webhook URL in the Africa’s Talking dashboard:- Log in to Africa’s Talking Dashboard
- Navigate to SMS > Callback URLs
- Set Delivery Reports URL:
https://your-domain.com/api/v1/sms/webhook - Set Incoming Messages URL:
https://your-domain.com/api/v1/sms/webhook - Save and test the configuration
Testing
Local Testing with ngrok
Test Incoming SMS
Send a test SMS to your shortcode or long number:Expected Response
Monitoring and Debugging
Check Webhook Logs
Monitor webhook activity in your application logs:Africa’s Talking Dashboard
View delivery reports and webhook attempts in the dashboard:- SMS > Sent Messages: View delivery status
- SMS > Received Messages: View incoming messages
- Logs: Check webhook delivery attempts and responses
Error Handling
| Error | Cause | Solution |
|---|---|---|
| 401 Unauthorized | Invalid signature | Verify webhook secret configuration |
| 400 Bad Request | Malformed payload | Check payload format and required fields |
| 500 Internal Error | Server error | Check application logs and database connection |
| Timeout | Slow response | Optimize webhook handler (use async processing) |
Related Endpoints
- Send SMS - Send SMS messages
- Bulk SMS - Send bulk SMS messages
- Contract SMS - Send contract notifications