Connect Twilio WhatsApp to Meta and Your Phone Number (Fast) — Seamless with Optimly
Overview
This guide shows you how to connect a WhatsApp number to Twilio (an official WhatsApp Business Solution Provider), link it to your Meta Business account, verify your phone number, and start sending/receiving messages. We’ll also show how to wire everything into Optimly so you can launch a production-ready WhatsApp assistant with analytics in minutes.
Prerequisites
- Twilio account (free to start)
- A phone number you own that can receive SMS or a voice call for verification and is not currently active on WhatsApp (consumer or Business app)
- Meta Business Manager account with admin access
Tip: If your number is already registered on WhatsApp, delete that account from the app before onboarding it to Twilio.
Quickest Start: Twilio WhatsApp Sandbox (for testing)
If you want to try WhatsApp messaging instantly without connecting your own number yet, use the Sandbox.
- Log into the Twilio Console.
- Go to
Messaging > Try it out > Send a WhatsApp message
. - Follow the instructions to send a unique code (e.g.,
join wide-rose
) from your personal WhatsApp to the Twilio Sandbox number. - Once joined, you can send/receive messages via the API between your number and the Sandbox.
Notes:
- Great for testing. Not for production.
- Users must opt in by sending the join code first.
Production Setup: Connect Your Own WhatsApp Number
Twilio provides a guided onboarding flow that connects your Meta Business account, creates/selects a WhatsApp Business Account (WABA), and verifies your number.
Step 1 — Start in Twilio Console
- Go to
Messaging > Senders > WhatsApp Senders
. - Click
New WhatsApp Sender
to begin the self-serve onboarding.
Step 2 — Connect Meta Business
- A Meta pop-up opens. Sign in with a Facebook profile that has Admin access to your Meta Business Manager.
- Approve Twilio permissions to manage WhatsApp on your behalf.
Step 3 — Create or Select Your WABA
- Choose an existing WhatsApp Business Account or create a new one.
Step 4 — Configure Business Profile
- Display Name: Must match or clearly relate to your business. Misaligned names are a common reason for rejection.
- Category and Description: Select your industry and write a short description.
Step 5 — Provide and Verify Your Phone Number
- Enter the number you want to use.
- Choose verification via SMS or voice call and enter the 6-digit code you receive.
- Ensure the number is not active on WhatsApp; if it is, remove it first in the app.
Step 6 — Approval
- Phone number verification is instant.
- Business profile and Display Name review typically completes within minutes to a few hours (occasionally up to 1–2 days).
- View status under
Messaging > Senders > WhatsApp Senders
in Twilio.
Step 7 — Configure Webhooks (Inbound Messages)
Once your number is approved:
- In
WhatsApp Senders
, click your number. - Open the
Configure
tab. - In
A MESSAGE COMES IN
, set your webhook URL (your app endpoint that processes inbound messages from Twilio). - Save changes.
Optional: You can also configure a status callback URL for delivery/read receipts.
Key Policies and Messaging Rules
- 24-Hour Session Window: You can send free-form messages only within 24 hours of the user’s last message.
- Message Templates: To start or restart a conversation outside the 24-hour window, use pre-approved templates. Create and submit templates from the Twilio Console.
- Compliance: Follow WhatsApp Business and Commerce Policies. Avoid unsolicited or spammy outreach.
Example: Simple Inbound Webhook (Node.js)
Below is a minimal Express handler that replies to an incoming WhatsApp message using Twilio’s helper library:
// npm install express twilio body-parser
const express = require('express');
const bodyParser = require('body-parser');
const { twiml: { MessagingResponse } } = require('twilio');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/whatsapp/webhook', (req, res) => {
const twiml = new MessagingResponse();
const msg = twiml.message();
msg.body('Thanks for reaching out! We will get back shortly.');
res.type('text/xml').send(twiml.toString());
});
app.listen(3000, () => console.log('Webhook listening on port 3000'));
Set your Twilio WhatsApp sender’s A MESSAGE COMES IN
to https://your-domain.com/whatsapp/webhook
.
Connect Twilio WhatsApp to Optimly (Fastest Path)
Optimly makes WhatsApp integration simple—no custom servers required. Once your number is approved in Twilio, you can plug it into Optimly and start capturing conversations and analytics immediately.
- In the Optimly dashboard, open your Agent and go to
Integrations
. - Choose
WhatsApp via Twilio
. - Paste your Twilio credentials (Account SID and Auth Token) and your approved WhatsApp Sender (phone number / sender ID).
- Copy the Optimly-provided webhook URL and set it in Twilio (
A MESSAGE COMES IN
). - Save. Your agent is now active on WhatsApp, with analytics and guardrails out of the box.
Benefits with Optimly:
- No-code setup and instant routing to your agent
- Message analytics, satisfaction signals, and conversation insights
- Template support and policy-aware messaging flows
- Production-ready in minutes
Troubleshooting
- Display Name rejected: Ensure it closely matches your business name and complies with WhatsApp’s naming guidelines.
- Number already registered: Remove the WhatsApp account from the app before onboarding to Twilio.
- Webhook not firing: Double-check the sender configuration in Twilio, your public HTTPS URL, and HTTP 200 responses.
- Outside 24h window: Use an approved message template to initiate the conversation.
Frequently Asked Questions
Can I test without using my own number?
Yes—use the Twilio WhatsApp Sandbox for quick testing.
How long does approval take?
Usually minutes to a few hours; occasionally up to 1–2 days.
Do I need a Meta Business account?
Yes, WhatsApp onboarding is tied to Meta Business Manager (WABA).
Can Optimly handle everything for me?
Yes. After your number is approved in Twilio, Optimly can handle message routing, analytics, and templates—no code or servers required.
Launch on WhatsApp with Optimly
Ready to go live on WhatsApp in minutes? Connect Twilio, approve your number, and plug into Optimly for an end-to-end, policy-compliant experience.