Skip to content

Commit 42cd214

Browse files
authored
Merge pull request #314 from dimagi/changelog-pr-3062-76
Changelog + Docs: Support sending whatsapp template messages (Cloud API only) (OCS #3062)
2 parents bc618bd + e6e5f5a commit 42cd214

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ hide:
55

66
# Changelog
77
## Mar 23, 2026
8+
* **NEW** The Meta Cloud API WhatsApp provider now supports **template messages** as a fallback when the 24-hour service window has expired. When a bot cannot send a message due to an expired window, it automatically sends a pre-configured WhatsApp template instead of silently dropping the message.
89
* **BUG** Fixed an issue where timeout triggers stopped firing after publishing a new experiment version. Sessions created before the publish were silently excluded from timeout detection.
910

1011
## Mar 19, 2026

docs/how-to/whatsapp_meta_cloud_api.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ To add the provider in OCS:
114114
- **System User Access Token**
115115
- **App Secret**
116116
- **Webhook Verify Token**
117+
- **Template Language Code** — the language code for the out-of-service-window template (defaults to `en`; see [Out-of-service-window template messages](#out-of-service-window-template-messages) below)
117118
5. Click **Save**.
118119

119120
The provider is now available to use when creating channels.
@@ -133,6 +134,70 @@ Open Chat Studio validates the phone number against your WhatsApp Business Accou
133134

134135
---
135136

137+
## Out-of-service-window template messages
138+
139+
### What is the 24-hour service window?
140+
141+
WhatsApp restricts when businesses can send messages to users. Once a user sends a message to your business number, a **24-hour service window** opens. During that window, your chatbot can reply freely. After 24 hours of inactivity from the user, the window closes and the WhatsApp API rejects any outbound messages.
142+
143+
Without a fallback, a bot reply sent outside the service window is silently dropped. The out-of-service-window template message feature prevents this by automatically substituting a pre-approved WhatsApp message template when the window has expired.
144+
145+
!!! info "Automatic fallback"
146+
The fallback is automatic — no manual toggle is required. When the service window has expired, OCS attempts to send the configured template in place of the original message. If the template has not been created in Meta, the attempt fails gracefully without interrupting service.
147+
148+
### Voice message fallback chain
149+
150+
When a voice message fails because the service window has expired, OCS first falls back to sending the content as a text message. If the text message also fails due to the expired window, the template fallback applies. This means the template covers both text and voice-originated replies.
151+
152+
### Create the required template in Meta Business Manager
153+
154+
You must create a WhatsApp message template in your Meta Business account before the fallback can work. Meta requires templates to be reviewed and approved before they can be sent.
155+
156+
1. Go to [business.facebook.com](https://business.facebook.com) and find where to manage your WhatsApp message templates.
157+
2. Create a new template with the following required settings:
158+
159+
| Setting | Required value |
160+
|---|---|
161+
| Category | **Utility** (recommended) or **Marketing** |
162+
| Template name | `new_bot_message` |
163+
| Language | Select the language that matches your **Template Language Code** in OCS |
164+
165+
3. In the **Body** section, add a single text variable named `bot_message`. This variable will be replaced with the bot's actual message when sent.
166+
167+
4. Submit the template and wait for Meta to approve it.
168+
169+
!!! warning "Template name and variable must match exactly"
170+
The template name must be `new_bot_message` exactly, and it must have a single template variable (text type) named `bot_message`. OCS looks up this template by name and passes the message via this variable. If either does not match, the fallback will not work.
171+
172+
!!! warning "Template approval required"
173+
The template cannot be used until Meta approves it. Approval typically takes a few minutes to a few hours but may take longer. Until approval is granted, the fallback will fail silently.
174+
175+
### Character limits
176+
177+
| Element | Limit |
178+
|---|---|
179+
| Template static text | 100 characters |
180+
| Dynamic message content (`bot_message`) | 974 characters |
181+
182+
If the bot's outgoing message exceeds 974 characters, OCS automatically splits it at word boundaries and sends it across multiple template messages.
183+
184+
### Set the template language code in OCS
185+
186+
The **Template Language Code** field in the Meta Cloud API provider form tells OCS which language variant of the `new_bot_message` template to use when sending the fallback message.
187+
188+
- The default value is `en` (English).
189+
- Change this value to match the language you selected when creating the template in Meta Business Manager.
190+
- Common codes include `en_US`, `es`, `fr`, `pt_BR`. For the full list, see the [Meta locale codes reference](https://developers.facebook.com/docs/whatsapp/api/messages/message-templates#supported-languages).
191+
192+
To update the language code:
193+
194+
1. Navigate to **Team Settings** > **Messaging Providers** in OCS.
195+
2. Click **Edit** on your Meta Cloud API provider.
196+
3. Update the **Template Language Code** field.
197+
4. Click **Save**.
198+
199+
---
200+
136201
## 4. Configure the Webhook in Your Meta App
137202

138203
!!! warning "Order matters"
@@ -218,6 +283,16 @@ This is almost always caused by the system user's access token not having permis
218283
- Check that the channel is linked to the correct chatbot.
219284
- Check the **Webhook Logs** in your Meta App dashboard to see whether delivery attempts are succeeding or returning errors.
220285

286+
### The out-of-service-window template message is not being sent
287+
288+
If the bot is not reaching users after the 24-hour service window expires:
289+
290+
- Confirm that the template named `ocs_out_of_service_window` exists in your Meta Business account under **WhatsApp Manager** > **Account tools** > **Message templates**.
291+
- Confirm the template status is **Approved**. Templates that are pending review or that have been rejected cannot be sent.
292+
- Confirm that the **Template Language Code** in your OCS provider settings matches the language of the approved template exactly (for example, `en` vs `en_US`).
293+
- Confirm that the template body variable is named `{{1}}` and that the static text surrounding it does not exceed 100 characters.
294+
- If the template was recently approved, wait a few minutes and try again — there may be a short propagation delay.
295+
221296
---
222297

223298
## See also

0 commit comments

Comments
 (0)