WhatsApp Template Setup Guide for Twilio
π± WhatsApp Business Messaging Restrictionsβ
WhatsApp has strict policies for business messaging to prevent spam and protect users:
24-Hour Messaging Windowβ
- You can only send freeform messages within a 24-hour window after a customer last messaged you
- Outside this window, you MUST use pre-approved Message Templates
- This applies to:
- β First-time messages to customers (invoices, notifications, etc.)
- β Messages after 24 hours of customer silence
- β Replies within 24 hours of customer message
Error Code 63016β
If you see this error: Failed to send freeform message because you are outside the allowed window, it means you need to use a Message Template.
π Setting Up WhatsApp Message Templatesβ
Step 1: Access Twilio Content Templatesβ
- Log in to Twilio Console
- Navigate to: Messaging β Content Templates β Content Template Builder
- Click Create new Template
Step 2: Choose Template Typeβ
- WhatsApp (Select this)
- Template Language: Choose your language (e.g., English, Spanish)
Step 3: Create Your Templateβ
Template Structure:β
Templates consist of:
- Template Name: Internal identifier (e.g.,
invoice_whatsapp) - Category: Purpose of message
TRANSACTIONAL: Invoices, orders, confirmationsMARKETING: Promotions, offersUTILITY: Account updates, reminders
- Header (Optional): Image, document, or text
- Body: Main message content with variables
- Footer (Optional): Additional info
- Buttons (Optional): Call-to-action buttons
π Template Examples for FlowPOSβ
1. Invoice Templateβ
Template Name: invoice_whatsapp
Category: TRANSACTIONAL
Language: English
Body:
Hello {{1}},
Your invoice #{{2}} has been generated.
Amount due: {{3}}
Due date: {{4}}
Thank you for your business!
Variables:
{{1}}= Customer Name{{2}}= Invoice Number{{3}}= Amount (formatted){{4}}= Due Date
2. Payment Reminder Templateβ
Template Name: payment_reminder_whatsapp
Category: TRANSACTIONAL
Language: English
Body:
Hi {{1}},
This is a reminder that invoice #{{2}} for {{3}} is due on {{4}}.
Please make payment at your earliest convenience.
Thank you!
Variables:
{{1}}= Customer Name{{2}}= Invoice Number{{3}}= Amount{{4}}= Due Date
3. Order Confirmation Templateβ
Template Name: order_confirmation_whatsapp
Category: TRANSACTIONAL
Language: English
Body:
Hi {{1}},
Your order #{{2}} has been confirmed!
Total: {{3}}
Estimated delivery: {{4}}
Thank you for shopping with {{5}}!
Variables:
{{1}}= Customer Name{{2}}= Order Number{{3}}= Total Amount{{4}}= Delivery Date{{5}}= Business Name
4. Low Stock Alert Templateβ
Template Name: low_stock_alert_whatsapp
Category: UTILITY
Language: English
Body:
β οΈ Low Stock Alert
Product: {{1}}
Current stock: {{2}} units
Reorder level: {{3}} units
Please reorder soon to avoid stockouts.
Variables:
{{1}}= Product Name{{2}}= Current Stock{{3}}= Reorder Level
β Step 4: Submit for Approvalβ
- Review your template
- Click Submit for Approval
- Approval Time: Usually 1-24 hours (sometimes instant)
- You'll receive an email when approved/rejected
π Step 5: Get Template SIDβ
Once approved:
- Go to Messaging β Content Templates
- Find your template
- Click on it
- Copy the Content SID (format:
HXe835f49d0aa7f1639f7f8e4b8a1e6c1e)
π§ Step 6: Update FlowPOS Databaseβ
Option A: Via API (Recommended)β
Update the template in FlowPOS:
curl --location --request PATCH 'https://your-api-url.com/communication-templates/{template-id}' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"providerTemplateId": "HXe835f49d0aa7f1639f7f8e4b8a1e6c1e"
}'
Option B: Direct Database Updateβ
UPDATE communication_template
SET provider_template_id = 'HXe835f49d0aa7f1639f7f8e4b8a1e6c1e'
WHERE code = 'invoice_whatsapp'
AND channel = 'whatsapp';
π Step 7: Send WhatsApp Message with Templateβ
Using the APIβ
curl --location --request POST 'https://your-api-url.com/communications/send' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"businessId": "your-business-id",
"createdBy": "your-user-id",
"channel": "whatsapp",
"type": "invoice",
"recipientType": "customer",
"recipientId": "customer-id",
"recipientContact": "+50256917111",
"templateId": "template-id-from-flowpos",
"templateVariables": {
"1": "John Doe",
"2": "INV-001",
"3": "$150.00",
"4": "2025-11-01"
},
"priority": "normal"
}'
Important Notes:
- Variables are numbered:
"1","2","3", etc. (not"{{1}}") - Variables must be strings
- The system automatically uses the
providerTemplateIdfrom the template
π― Best Practicesβ
1. Template Naming Conventionβ
- Use descriptive names:
invoice_whatsapp,payment_reminder_whatsapp - Include channel in name for clarity
- Keep it consistent across your system
2. Variable Managementβ
- Use numbered variables
{{1}},{{2}}, etc. - Keep variable count reasonable (max 10-15)
- Document what each variable represents
3. Content Guidelinesβ
- Keep messages concise and clear
- Include business name for brand recognition
- Use emojis sparingly (β β β οΈ are good)
- Avoid spammy language
4. Testingβ
- Test templates with your own phone number first
- Verify all variables render correctly
- Check character limits (WhatsApp max: 4096 chars)
5. Fallback Strategyβ
- Have SMS templates as fallback
- Monitor delivery rates
- Handle template rejection gracefully
π Troubleshootingβ
Template Rejectedβ
Common Reasons:
- β Contains promotional language in TRANSACTIONAL category
- β Unclear purpose or business use case
- β Grammar or spelling errors
- β Misleading content
Solution: Review WhatsApp's Template Guidelines
Error 63016: Outside 24-Hour Windowβ
Solution: You're using freeform messages instead of templates. Use the template system described above.
Template Variables Not Workingβ
Check:
- Variables are numbered correctly (
1,2,3, not{{1}}) - All required variables are provided
- Variables are strings, not numbers or objects
Template Not Foundβ
Check:
- Template is approved by Meta/WhatsApp
- Correct Content SID is stored in
provider_template_id - Template is active in FlowPOS database
π Monitoringβ
Track Template Performanceβ
-
Twilio Console:
- Go to Messaging β Insights
- View delivery rates, open rates
-
FlowPOS Dashboard:
- Check
communicationtable - Monitor
statusfield - Track
deliveredAt,failedAttimestamps
- Check
π Security Notesβ
- Never hardcode Content SIDs in code
- Store SIDs in database (
provider_template_idfield) - Use environment variables for Twilio credentials
- Implement rate limiting to avoid hitting Twilio limits
π Additional Resourcesβ
- Twilio WhatsApp Business Platform
- WhatsApp Message Templates
- Twilio Content API
- WhatsApp Business Policy
π‘ Next Stepsβ
- β Create your first template
- β Wait for approval
- β Update FlowPOS database with Content SID
- β Test sending a message
- β Monitor delivery and adjust as needed
π Successβ
You're now ready to send WhatsApp messages at scale without hitting the 24-hour window restriction!
For questions or issues, refer to the troubleshooting section or contact support.