Send WhatsApp Messages with Twilio ā Complete 2025 Guide
Twilioās WhatsApp Business API lets any developer or small business deliver appointment reminders, dispatch alerts or boarding passes straight to a customerās WhatsApp inbox. The set-up is shorter than a coffee break and costs less than a London bus fare.
What You Need Before You Start
- A Twilio account (free trial gives you Ā£12 credit ā enough for roughly 1,200 UK WhatsApp messages)
- A mobile phone with WhatsApp installed (for testing)
- Python 3.9+ or Node.js 18+ (examples below use Python)
Step 1 ā Activate the WhatsApp Sandbox
- Log in to console.twilio.com
- Choose āExplore Productsā ā āMessagingā ā āTry WhatsAppā
- Copy the **sandbox number** (it looks like +1 415 523 8886) and the **join code** (e.g.,
join abc123) - Open WhatsApp on your phone, send the join code to the sandbox number ā this pairs your handset for testing
Step 2 ā Grab Your Credentials
Still in the console, note:
- Account SID (starts ACā¦)
- Auth Token (keep this private)
Store them as environment variables so you never hard-code keys:
export TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxx
export TWILIO_AUTH_TOKEN=your_auth_token
Step 3 ā Install Twilioās Helper Library
pip install twilio
Step 4 ā Send Your First Message
Create send_whatsapp.py and paste:
import os
from twilio.rest import Client
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)
message = client.messages.create(
from_="whatsapp:+14155238886", # sandbox number
to="whatsapp:+447700900123", # your phone in E.164
body="Hello from Twilio and husham.com!"
)
print(f"Message sent: {message.sid}")
Run:
python send_whatsapp.py
Your phone should receive the text within seconds.
Step 5 ā Using a Template (Business-Initiated)
Outside the 24-hour ācustomer care windowā you must use a Twilio-approved template. In the console:
- āMessagingā ā āTemplatesā ā āCreate a new templateā
- Example:
Your appointment is on {{1}} at {{2}}. - Submit for WhatsApp approval (usually 2ā4 minutes in 2025)
Once approved, swap the body for a content_sid call:
message = client.messages.create(
from_="whatsapp:+14155238886",
to="whatsapp:+447700900123",
content_sid="HXb5b62575e6e4ff6129ad7c8efe1f983e",
content_variables='{"1":"22 July 2026","2":"3:15pm"}'
)
Pricing Quick View (October 2025)
- UK ā 4.2 p per outbound template message
- UK ā 2.1 p per outbound āsessionā message (inside 24-hour window)
- Incoming messages are free
- No monthly fee; you only pay for what you send
Common Pitfalls
- Wrong prefix ā always use
whatsapp:before the number - Non-E.164 ā UK mobiles must start +447, not 07
- Template outside window ā WhatsApp will reject free-form text after 24 hours
Going Live (Next Steps)
- Buy a real Twilio number (Ā£1/month)
- Complete Facebook Business verification (WhatsApp owns the pipes)
- Submit your display name for approval (24-hour SLA)
- Replace the sandbox number with your own in the code
Bottom Line
With a single API call you can reach customers where open rates exceed 90%. Twilioās pay-as-you-go model keeps costs predictable, and the sandbox lets you prototype for free. For real-world gotchas, template ideas or billing hacks, jump into the husham.com forum ā the thread is updated every time WhatsApp tweaks its policy.
Pricing & policy accurate: 28 October 2025