Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Send WhatsApp Notification Messages with Templates



Prerequisites

prerequisites page anchor

Before you begin, ensure you have the following:

  • An active Twilio account with WhatsApp access
  • A WhatsApp Business Account (WABA) set up
  • Access to Twilio Console messaging services
  • Understanding of WhatsApp customer service window concept

WhatsApp message templates overview

whatsapp-message-templates-overview page anchor

WhatsApp message templates are pre-approved message formats that allow businesses to send notifications to users outside the 24-hour customer service window.

A WhatsApp message template is a message format that you can use over and over again to message users. You can use templates once users have opted-in and given your app permission to send them messages. To use a message template, you must first create and submit it to WhatsApp using the Content Template Builder or Content API. Meta reviews and approves each message template to maintain high-quality content and avoid spam. Once WhatsApp has approved your template, you can use the Content Template to send notifications. For more info on WhatsApp template approval process, see Message template approvals and statuses.

Templates use placeholder values that Content Variables replace with dynamic content when you send the message:

  • Your appointment for {{1}} is scheduled for {{2}}. Need to reschedule? Tap below to reply.
  • Example of a message sent using this template: Your appointment for your doctor's appointment is scheduled for Tuesday at 10 AM. Need to reschedule? Tap below to reply.
  • Note that a single placeholder can contain multiple words.

Think of your template message as a conversation starter; the goal is to convert this initial message into a two-way conversation when the user replies. Two-way conversations provide higher value because you are engaging with your end user. In addition, they reduce your spend because WhatsApp does not charge for free-form outbound messages nor Utility template messages within the 24-hour customer service window. To learn more about pricing, see our pricing page(link takes you to an external page).

Customer service window for free-form messages

customer-service-window-for-free-form-messages page anchor

The 24-hour customer service window allows you to send template-free messages after a user initiates contact.

When a WhatsApp user sends your application a message, your application gains a 24-hour customer service window. This applies whether it's a reply to your outbound messages or they initiate communication.

This window lasts for 24 hours after the last inbound message you receive.

During this window, you can send messages that don't require templates. When your application sends a message to a WhatsApp user outside this window, the message must use an approved template.

Templates pre-provisioned for the Sandbox

templates-pre-provisioned-for-the-sandbox page anchor

Twilio has pre-provisioned Content Templates using each of WhatsApp template categories for testing in the WhatsApp Sandbox(link takes you to an external page). The Sandbox guides you through using Content Templates and Content Variables and provides sample code snippets using Twilio server-side SDKs.

For more information, see the guide to getting started with the Twilio Sandbox for WhatsApp.


WhatsApp template categories

whatsapp-template-categories page anchor

WhatsApp requires you to classify all message templates into one of three specific categories that determine pricing and approval requirements. Your WhatsApp message templates must fall into one of the following categories.

  • Authentication: Authenticate users with one-time passcodes. Meta determines the body text and you cannot change it.
  • Utility: Share important information related to a specific, agreed-upon transaction and accomplish one of the following: confirm, suspend, or change a transaction or subscription.
  • Marketing: Send promotional offers, product announcements, and more to increase awareness and engagement. Meta will classify any template that has a mix of utility and marketing content as a marketing template.

Meta bases their message fees on template categories. Any templates that don't result from an explicit end user request will likely be categorized by Meta as "Marketing." Learn more in our pricing page(link takes you to an external page) and refer to our best practices(link takes you to an external page) for guidance on creating WhatsApp templates. Meta determines template categories at their sole discretion.


Creating message templates and submitting them for approval

creating-message-templates-and-submitting-them-for-approval page anchor

Creating custom message templates allows you to send notifications outside the 24-hour customer service window.

Content Templates are omnichannel templates and offer access to WhatsApp templates. Content Templates are message templates that you can use on any channel, including WhatsApp. They offer flexibility and help ensure your implementation remains compatible with future updates at Twilio. For more detailed information about Content Templates and how to use them with WhatsApp, refer to this page.

FeatureWhat is supported in content templates
Supported channelsWhatsApp, SMS, MMS, Facebook Messenger
Sending messagesSend messages with a ContentSid field
Messaging ServiceRequired
Rich feature supportLatest rich features supported by Twilio, such as catalog, carousels, media templates, and dynamic buttons
API to manage templatesContent API
UI to manage templatesContent Editor in the Twilio Console, go to Messaging > Content Editor

Set up WhatsApp message templates in your Twilio account

set-up-whatsapp-message-templates-in-your-twilio-account page anchor

To create a WhatsApp template in your Twilio account, follow these steps:

  1. Go to Twilio Console > Messaging > Content Template Builder(link takes you to an external page).

  2. Click Create new.

    Content Template Builder with highlighted Messaging menu and 'Create your first content template' button.
    (information)

    Info

    If you are creating a template for the first time, you will see the Create your first content template button. Click it to create templates.

  3. On the next screen, fill out the information to submit to WhatsApp. WhatsApp's team uses the information you submit to approve or reject your template submission.

    For more information, refer to this page on creating Content Templates.

    • Template name: The name can only contain lowercase alphanumeric characters and underscores. Tip: Use a name that helps WhatsApp reviewer understand the purpose of your message, for example, "order_delivery" rather than "template_1".
    • Template category: You must select the category that matches WhatsApp definition. See Meta's docs(link takes you to an external page) for definitions and examples. Authentication templates have special constraints. See Authentication template requirements for more information.
    • Message language: Select from the languages provided by WhatsApp.
    • Message body: The text of the message that you want to send. WhatsApp doesn't allow multiple sequential line breaks.
    • Buttons and other rich features: You can add a variety of button types and other rich features into a content template. To see a full list of supported template types, see our content type overview here.
  4. After you fill out the message template, click Save and submit for WhatsApp approval.

Configure WhatsApp template with call to action for website visit, including body text and URL fields.

If your template includes placeholders (like "Hello {{1}}! We've received your request regarding {{2}}."), a modal will appear for you to add sample content for each placeholder. Enter sample text for each placeholder and then click Save and submit to submit your template to WhatsApp.

Form to add sample data for message templates and button URLs with input fields and save option.

Note: Once you submit a template, it cannot be edited.

Refer to the WhatsApp documentation to learn more about message template formatting and supported languages(link takes you to an external page).

Authentication template requirements

authentication-template-requirements page anchor

Authentication templates have specific restrictions and pre-defined formatting set by WhatsApp for security compliance. When creating a template with the category of Authentication (i.e., Authentication Templates) using WhatsApp Templates, certain restrictions apply to comply with WhatsApp policies:

  1. WhatsApp sets the body text of the template for every language and you cannot edit it.
  2. You must include a Copy Code button, which users can use to copy the one-time passcode. You can edit the button label per language.

To learn more about the WhatsApp authentication content type, see WhatsApp authentication.

WhatsApp evaluates each template language translation on an individual basis. Content Templates offer searching and filtering tools to help manage your templates.

Removing WhatsApp message templates

removing-whatsapp-message-templates page anchor

To delete a message template:

  • Click on the template name on the WhatsApp Message Templates page.
  • Click Delete at the bottom of the page.
  • Alternatively, click on the 3-dot menu on the right-hand side of the template and select Delete.

Per WhatsApp guidelines, you may not reuse the name of a deleted template for 30 days after deletion.

(information)

Info

WhatsApp supports up to 6,000 template translations in total, across all templates, per account. Previous limits of 250 and 1,500 templates no longer apply.

Submitting templates for approval

submitting-templates-for-approval page anchor

WhatsApp reviews most templates submitted for approval within minutes. For detailed information about the approval process, refer to this article.


Send WhatsApp messages using approved templates

send-whatsapp-messages-using-approved-templates page anchor

Sending templated WhatsApp messages requires using the ContentSid parameter along with any necessary ContentVariables for dynamic content. To send a templated message, include the ContentSid parameter in the call with the HX content SID of the template you would like to send. If your template includes variables, set them using the ContentVariables parameter. For more information, see Send templates created with the Content Template Builder.

The following example demonstrates how to structure template variables for a order confirmation message:

Hi {{1}}! Thanks for placing an order with us. We'll let you know once we process and deliver your order. Your order number is {{2}}. Thanks

In the ContentVariables parameter of the message resource, provide the end user's information as follows:

ContentVariables={ "1": "Joe", "2": "O12235234" }
Send a WhatsApp message using a message templateLink to code sample: Send a WhatsApp message using a message template
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.messages.create({
12
contentSid: "HXXXXXXXXX",
13
contentVariables: JSON.stringify({ 1: "Name" }),
14
from: "whatsapp:+15005550006",
15
messagingServiceSid: "MGXXXXXXXX",
16
to: "whatsapp:+18551234567",
17
});
18
19
console.log(message.body);
20
}
21
22
createMessage();

Response

Note about this response
1
{
2
"account_sid": "ACXXXXXXXXX",
3
"api_version": "2010-04-01",
4
"body": "Hello! 👍",
5
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
6
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
7
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
8
"direction": "outbound-api",
9
"error_code": null,
10
"error_message": null,
11
"from": "whatsapp:+15005550006",
12
"num_media": "0",
13
"num_segments": "1",
14
"price": null,
15
"price_unit": null,
16
"messaging_service_sid": "MGXXXXXXXX",
17
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"status": "queued",
19
"subresource_uris": {
20
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
21
},
22
"to": "whatsapp:+18551234567",
23
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
24
}

Including line breaks and escape characters in templates

including-line-breaks-and-escape-characters-in-templates page anchor

If you are rendering line breaks or other escaped characters, encode the line breaks properly based on the language you are using. The Twilio Console may show line breaks and other escaped characters in their raw form, such as \n.


Initiate the customer service window with a generic template

initiate-the-customer-service-window-with-a-generic-template page anchor

You may want to send different types of notifications and messages to your users. However, it is difficult and inefficient to go through the template approval process for every type of message you want to send to your end users.

For example, you might want to send a time-sensitive message such as "We are having a company-wide announcement at 11 AM." WhatsApp is unlikely to approve this template, making it challenging to build a real notification flow.

To work around this, you can create a generic template that asks your end users to respond. An example of a generic notification template you can submit for approval is:

"Hello {{1}}, we have a new update regarding your account. Respond to this message to receive it. Have a nice day!"

Once an end user replies to this templated message, it initiates the 24-hour customer service window, during which your business can send free-form messages.


Monitoring live templates

monitoring-live-templates page anchor

Once you start using your templates, monitor them for excessive negative user feedback.

Paused and deactivated templates

paused-and-deactivated-templates page anchor

WhatsApp may pause templates that receive excessive negative feedback to protect sender quality ratings. If end users repeatedly block or report spam in association with a message template, WhatsApp will pause the template for a period of time. Pausing durations are as follows:

  • First instance: Paused for 3 hours
  • Second instance: Paused for 6 hours
  • Third instance: Deactivated

When WhatsApp pauses a template a third time, WhatsApp will permanently deactivate it. Messages using paused or deactivated templates will fail. Paused and deactivated message templates that you attempt to send do not count against the daily messaging limit.

Getting alerts for paused, deactivated, and rejected templates

getting-alerts-for-paused-deactivated-and-rejected-templates page anchor

Twilio can send a notification using Twilio Alerts when a template status changes to paused, disabled, or rejected. To get notified, create an alert for error 63041 (paused), 63042 (disabled), or 63040 (rejected). We also offer alarms for approved templates with code 63046.


Frequently Asked Questions

frequently-asked-questions page anchor

How long does template approval take?

how-long-does-template-approval-take page anchor

WhatsApp reviews and approves most templates within minutes, though complex templates may take longer.

Can you edit a template after submission?

can-you-edit-a-template-after-submission page anchor

No, submitted templates cannot be edited. You must create another template with the desired changes.

How many templates can you create?

how-many-templates-can-you-create page anchor

WhatsApp supports up to 6,000 template translations total across all templates per account.

What happens if users report your template as spam?

what-happens-if-users-report-your-template-as-spam page anchor

WhatsApp may pause your template for 3-6 hours, and permanently deactivate it after the third pause.


After understanding WhatsApp message templates, explore these related resources: