Commit a5b0ccd
fix: Update WhatsApp OTP template to single variable format (#974)
## Summary
- Fix Twilio error 21656 ("The ContentVariables you are using are not
valid") when sending WhatsApp OTP messages
- Update WhatsApp OTP template configuration to use single variable
format as required by Twilio/Meta's updated authentication template
requirements
- Modify validation logic to allow extra variables to be passed (and
ignored) for backward compatibility
## Background
Twilio/Meta updated their WhatsApp authentication template format.
Authentication templates now only accept a **single variable** (the OTP
code).
**Before:** `{"1":"123456","2":"MyOrg"}` ❌
**After:** `{"1":"123456"}` ✅
Reference: https://www.twilio.com/docs/content/whatsappauthentication
## Changes
- `internal/message/twilio_whatsapp_client.go`:
- Removed `TemplateVarOrgName` from `MessageTypeReceiverOTP`
configuration
- Updated `formatContentVariables` validation to check only for required
variables (extra variables are allowed but ignored)
- `internal/message/twilio_whatsapp_client_test.go`:
- Updated test expectations for OTP formatting
- Added test case for extra variables being allowed
- Updated error message expectations
## Test plan
- [x] Unit tests pass (`go test ./internal/message/...`)
- [x] Integration test with real Twilio credentials - WhatsApp OTP
message sent successfully
- [X] Manual verification: OTP received on WhatsApp
Co-authored-by: Marwen Abid <[email protected]>1 parent dd48910 commit a5b0ccd
File tree
2 files changed
+13
-13
lines changed- internal/message
2 files changed
+13
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
| |||
95 | 94 | | |
96 | 95 | | |
97 | 96 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
| 365 | + | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
0 commit comments