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