1. Joining the Twilio Sandbox Before you can start receiving messages via Webhook, you need to join the WhatsApp Sandbox. Here's how: In your Twilio Console, navigate to Messaging > Try it Out > Send a WhatsApp message. You’ll see a Sandbox section. Send the provided code (something like "join magic-pizza") to the given WhatsApp number. In my case, it was "join control-type". ✅ Done! Your phone is now linked to the Sandbox. Important: Only registered numbers can send and receive messages in the Sandbox. If you change phones or SIMs, you’ll need to register again. 2. Setting up your Webhook URL Next, you’ll tell Twilio where to send incoming messages. In the Sandbox settings, set your Webhook URL for incoming messages (e.g., https://yourdomain.com/webhook). You can do this on the same page, under the "Sandbox Settings" tab. Make sure your server can accept POST requests from Twilio. Now, every time that phone number receives a WhatsApp message, Twilio will send the message to your webhook so you can handle the incoming message. Twilio will send a payload like this: { "SmsMessageSid": "SMc8df133659ef2ca4251da5b1ac5453cdg", "NumMedia": "0", "ProfileName": "John Smith", "MessageType": "text", "SmsSid": "SMc8df133659ef2ca4251da5b1ac5453cdg", "WaId": "+157822787582693", "SmsStatus": "received", "Body": "The body of the message that you are receiving", "To": "whatsapp:+157822787584443", "NumSegments": "1", "ReferralNumMedia": "0", "MessageSid": "SMc8df133659ef2ca4251da5b1ac5453cdg", "AccountSid": "youraccountId", "From": "whatsapp:+157822787582693", "ApiVersion": "2010-04-01" } We'll code a real webhook handler in the next part

1. Joining the Twilio Sandbox
Before you can start receiving messages via Webhook, you need to join the WhatsApp Sandbox.
Here's how:
- In your Twilio Console, navigate to Messaging > Try it Out > Send a WhatsApp message.
- You’ll see a Sandbox section.
- Send the provided code (something like "join magic-pizza") to the given WhatsApp number. In my case, it was "join control-type".
✅ Done! Your phone is now linked to the Sandbox.
Important:
Only registered numbers can send and receive messages in the Sandbox. If you change phones or SIMs, you’ll need to register again.
2. Setting up your Webhook URL
Next, you’ll tell Twilio where to send incoming messages.
In the Sandbox settings, set your Webhook URL for incoming messages (e.g., https://yourdomain.com/webhook).
You can do this on the same page, under the "Sandbox Settings" tab.
Make sure your server can accept POST
requests from Twilio.
Now, every time that phone number receives a WhatsApp message, Twilio will send the message to your webhook so you can handle the incoming message.
Twilio will send a payload like this:
{
"SmsMessageSid": "SMc8df133659ef2ca4251da5b1ac5453cdg",
"NumMedia": "0",
"ProfileName": "John Smith",
"MessageType": "text",
"SmsSid": "SMc8df133659ef2ca4251da5b1ac5453cdg",
"WaId": "+157822787582693",
"SmsStatus": "received",
"Body": "The body of the message that you are receiving",
"To": "whatsapp:+157822787584443",
"NumSegments": "1",
"ReferralNumMedia": "0",
"MessageSid": "SMc8df133659ef2ca4251da5b1ac5453cdg",
"AccountSid": "youraccountId",
"From": "whatsapp:+157822787582693",
"ApiVersion": "2010-04-01"
}
We'll code a real webhook handler in the next part