Before beginning, ensure that you have created the necessary data extensions to store all your WhatsApp chat messaging contacts and opt-out requests.
Create a non-sendable data extension named "Whatsapp_Subscribers", which should be updated hourly using an external import process. This extension requires the following three columns:
| Field Name | Primary Key | Data Type | Required |
|---|---|---|---|
| Contactkey | Yes | Text | Yes |
| Mobilenumber | No | Phone | Yes |
| Locale | No | Locale | Yes |
Note: Only use a 2-character locale value.
Next, construct a non-sendable data extension named "Whatsapp_OptOut_Requests". This extension will store all opt-out requests and should have a retention set to 7 days. It needs the following columns:
| Field Name | Primary Key | Data Type | Required |
|---|---|---|---|
| Contactkey | Yes | Text | Yes |
| Mobilenumber | Yes | Phone | Yes |
| Optoutstatus | No | Number | Yes |
| Locale | No | Locale | Yes |
Subsequently, create a sendable data extension named "Whatsapp_QuickReply_OptOuts" to store opt-out requests from Quick Reply buttons this should have a retention set to 7 days. It needs two columns:
| Field Name | Primary Key | Data Type | Required |
|---|---|---|---|
| Contactkey | No | Text | Yes |
| Optoutstatus | No | Number | Yes |
Finally, create a non-sendable data extension named "Whatsapp_OptOut_History" to record the history of successful WhatsApp opt-outs. It should contain the following columns:
| Field Name | Primary Key | Data Type | Required |
|---|---|---|---|
| Contactkey | No | Text | Yes |
| Mobilenumber | No | Phone | Yes |
| Date_optedout | No | Date | Yes |
Note: Select 'Use current datetime' for Date_optedout.
Here are the steps to handle opt-outs when using Call to Action (CTA) message templates:
NOTE: When creating the Journey where you will send this WhatsApp message, within the entry data extension there should be two columns for mobile number and contact key respectively. In the example above, these columns are referred to as "mobilenumber" and "Contactkey."
%%[
var @mobilenumber, @Contactkey, @insertRow, @locale
/* Retrieve the URL parameters */
set @mobilenumber = QueryParameter('mobilenumber')
set @Contactkey = QueryParameter('Contactkey')
/* Lookup locale from the "Whatsapp_Subscribers" Data Extension */
set @locale = Lookup('Whatsapp_Subscribers', 'locale', 'Contactkey', @Contactkey)
/* Insert data into your Data Extension */
set @insertRow = InsertDE('Whatsapp_OptOut_Requests', 'mobilenumber', @mobilenumber, 'Contactkey', @Contactkey, 'locale', @locale, 'optOutStatus', '1')
]%%
/*
Only for testing to see if the values are coming through
Mobile: %%=v(@mobilenumber)=%%
Contactkey: %%=v(@Contactkey)=%%
Locale: %%=v(@locale)=%%
*/
For handling opt-outs when using Quick Reply message templates, follow these steps:
QUERY TO USE:
select WS.contactkey as Contactkey, WS.mobilenumber as mobilenumber, WS.locale as locale, WQR.optoutstatus as optoutstatus from [Whatsapp_Subscribers] as WS join [Whatsapp_QuickReply_OptOuts] as WQR on WS.contactkey = WQR.Contactkey
Note: Refer to "Automation Configuration to Handle WhatsApp Requests" below for further details.
QUERY TO USE:
select Contactkey as Contactkey, mobilenumber as mobilenumber from [Whatsapp_OptOut_Requests]
NOTE: You can verify a contact has been opted-out by navigating to their contact page in Contact Builder and clicking on the Attributes tab. Then scroll to the Chat Message Demographics section and click on their mobile number to open the Chat Message Subscriptions page. Here you should see the contact as "Opted Out."
000395648

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.