Skip to main content

Setting Up WhatsApp with Twilio

Rubaiyat Farhan avatar
Written by Rubaiyat Farhan
Updated over 2 months ago

Overview

WhatsApp is one of the most powerful channels for customer engagement, with over 2 billion users worldwide. However, setting up WhatsApp for business messaging requires several steps through Twilio's platform. This comprehensive guide walks you through the entire process.

Prerequisites

Before you begin, you'll need:

  • A Twilio account (create one at twilio.com if you don't have one)

  • A Facebook Business Manager account

  • A phone number dedicated to WhatsApp Business (cannot be an existing personal WhatsApp number)

  • Access to markopolo's Integrations settings

Step 1: Connect Twilio to markopolo

If Twilio isn't connected yet:

  1. In markopolo, navigate to Settings → Integrations

  2. Search for "Twilio" in the integration marketplace

  3. Click Connect

  4. You'll need your Twilio credentials:

    • Account SID (found in Twilio Console dashboard)

    • Auth Token (found in Twilio Console dashboard)

  5. Enter your credentials and click Connect

  6. Verify the connection is successful (green checkmark)

Step 2: Register Your WhatsApp Business Account in Twilio

Twilio provides a developer-friendly approach to implementing WhatsApp Business Platform, handling hosting, number setup, and providing a sandbox environment for testing.

Option A: For Testing (WhatsApp Sandbox)

The Twilio Sandbox for WhatsApp allows you to prototype and test your application without requiring full WhatsApp approval. You'll receive a Twilio-provided phone number and join code to connect your device for testing.

  1. In Twilio Console, go to Messaging → Try it out → Send a WhatsApp Message

  2. You'll see a Twilio sandbox number (e.g., +1 415 523 8886) and a join code (e.g., "join cozy-falcon")

  3. On your personal WhatsApp, send the join code to the Twilio number

  4. You're now connected and can test sending/receiving messages

  5. Note: Sandbox is for development only and has limitations on template messages

Option B: For Production (Full WhatsApp Business Account)

To send WhatsApp messages under your own brand, you need to register a WhatsApp sender with Twilio. Direct customers can use WhatsApp Self Sign-up for registration.

  1. In Twilio Console, navigate to Messaging → Senders → WhatsApp Senders

  2. Click Register a WhatsApp Sender or use WhatsApp Self Sign-up

  3. Provide your business information:

    • Company name (must match Facebook Business Manager)

    • Business website

    • Headquarters country

    • Business description and use case

  4. Select or purchase a phone number for WhatsApp:

    • Must be a number NOT already registered with WhatsApp

    • Must meet WhatsApp compatibility requirements and proper international format.

    • Can be a Twilio number or your own number

  5. Set your WhatsApp Business Display Name:

    • Must comply with Meta's display name guidelines - this will be visible to customers.

    • Meta reviews the name after registration, and if rejected, you're limited to 250 business-initiated messages per 24 hours.

    • Complete Facebook Business Verification

  6. Wait for approval (typically 1-2 business days)

Step 3: Create WhatsApp Message Templates

WhatsApp requires that business-initiated messages use pre-approved templates. Templates must be created and submitted to WhatsApp for approval before you can send messages outside the 24-hour customer service window.

Why templates are required: WhatsApp uses templates to maintain high-quality content and prevent spam. When customers send you a message, you have a 24-hour window to send free-form responses. Outside that window, you must use approved templates.

How to create templates:

  1. In Twilio Console, go to Messaging → Content Template Builder

  2. Click Create new (or "Create your first content template" if it's your first time)

  3. Fill out the template information:

    • Template name: Descriptive name (e.g., "order_confirmation")

    • Template language: Select your language

    • Content type: Choose the message type (text, media, interactive, etc.)

  4. Design your template content:

    • Write your message body

    • Use numbered placeholders for dynamic content: "Your appointment for {{1}} is scheduled for {{2}}"

    • Add header (optional), footer (optional), and call-to-action buttons

    • Provide variable samples for all placeholders - required for templates with media or requiring WhatsApp approval

  5. Select template category:

    • Marketing: Promotional offers, announcements, product updates

    • Utility: Order confirmations, shipping updates, account changes

    • Authentication: One-time passwords, verification codes

  6. Click Save and Submit for WhatsApp Approval

  7. Meta typically processes approvals within an hour, though some may take up to one business day TwilioTwilio

Template approval statuses:

Templates can have several statuses: Pending (under review), Approved (ready to use), Rejected (not approved), Paused (due to customer feedback), or Disabled (policy violation).

Step 4: Template Best Practices to Avoid Rejection

WhatsApp generally rejects templates if the format is incorrect, content violates policies, or the template is too generic with placeholders that could enable abuse.

Do:

  • Be specific with placeholders rather than generic - spell out expected content instead of using vague placeholders like "Important message: {{1}}"

  • Make it clear the user requested the interaction

  • Use selective emojis (fewer than 10 per template) to improve engagement.

  • Maintain a friendly, professional tone

  • When reopening 24-hour windows, reference the previous conversation: "I'm sorry I could not respond to your concerns yesterday. If you would like to continue, reply with YES."

Don't:

  • Use too many variables or generic placeholders

  • Include promotional content in Utility templates

  • Violate WhatsApp's Terms of Service or policies

  • Create misleading or abusive content

  • Attempt to reuse deleted template names within 30 days

    If rejected: The Twilio Console displays a rejection code explaining why. Submit a new template with a different name and delete the rejected one

Did this answer your question?