Articles in this section
Category / Section

How to Set Up WhatsApp in Twilio

Updated:

Twilio’s WhatsApp integration enables businesses to send and receive messages through the WhatsApp Business API, providing secure and scalable customer communication. This guide explains how to activate the Twilio Sandbox for testing and configure your WhatsApp Business profile for production use.

Prerequisites

Before starting, ensure you have:

  • A Twilio Account (with WhatsApp senders enabled)
  • Verified phone number (not linked to any existing WhatsApp account)
  • Compliance with WhatsApp Business Messaging Policy

Step-by-Step Setup Guide

Follow the steps below to set up your WhatsApp in Twilio.

1. Create a Twilio Account

  • Sign up or log in at Twilio.
  • Verify your email and phone number.
  • Note your Account SID and Auth Token (these are your API credentials).

2. Activate Twilio WhatsApp Sandbox

  • In the Twilio Console, go to Messaging → Try it out → WhatsApp.
  • Confirm terms and activate the WhatsApp Sandbox.
  • You’ll get:
    • Sandbox number
    • Join code for linking your personal WhatsApp to the sandbox.

3. Connect Your WhatsApp

  • Send the provided join message from your WhatsApp to the sandbox number.
  • This links your WhatsApp account for testing.
  • You can now send and receive messages in the sandbox environment.

4. Configure Messaging

  • Use Twilio’s API or Console to send messages:
    • For user-initiated chats, you can reply freely within 24 hours.
    • For business-initiated messages, use approved WhatsApp templates.

5. Move to Production

  • Get Meta approval for your WhatsApp Business Account.
  • Register your Twilio number as a WhatsApp sender.
  • Configure your business profile (name, email, website, category).

Business-initiated Messages and Templates

WhatsApp Business Platform requires the use of a message template for business-initiated messages. When a user sends your business a message, it opens a 24-hour customer service window during which you can send free-form outbound messages without a template. If you initiate a message before an end user messages you or if you send a reply outside of the 24-hour window, you can message users only with an approved message template.

Sending " join < your sandbox code >" to the Sandbox number starts a customer service window.

The Twilio Sandbox for WhatsApp comes with the following pre-approved templates for testing purposes:

  • Appointment Reminders: “Your appointment is coming up on {{1}} at {{2}}”.
  • Order Notifications: “Your {{1}} order of {{2}} has shipped and should be delivered on {{3}}. Details: {{4}}”.
  • Verification Codes: “Your {{1}} code is {{2}}”.

The double-bracketed numbers are placeholders for your custom values. In your code, provide these values as key-value pairs. For example, if you use the Appointment Reminders template, {“1”:“2025/7/15”,“2”:“3:00p.m.”} will show “Your appointment is coming up on 2025/7/15 at 3:00p.m.”.

Sandbox Limitations

  • You can only message end users who have joined your Sandbox. Messaging other users will fail with Error 63015.
  • The Sandbox supports functional testing, but not load testing of profile traffic.
  • The Sandbox number is a Twilio number and displays the Twilio logo.
  • The Sandbox number can only send one message every three seconds.
  • For business-initiated messages from the Sandbox, you can use only pre-approved templates.
  • The Sandbox session expires three days after joining. After this, end users need to rejoin the Sandbox.
  • Twilio provides the Sandbox with a shared phone number for all users.

Frequently Asked Questions (FAQs)

Q1: Do I need Meta approval for WhatsApp Business?
Yes, Meta approval is required for production use.

Q2: Can I use Twilio Sandbox for testing?
Yes, Twilio Sandbox allows testing without full approval.

Q3: What media types are supported?
Images, videos, audio, and documents (.pdf).

Q4: What happens if my WhatsApp Business Account is not approved by Meta?
You cannot move to production without Meta approval. You can still use the Twilio Sandbox for testing purposes.

Related Articles

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied