## Description This implementation adds support for the `media_name` parameter for WhatsApp document templates, resolving the issue where documents appear as "untitled" when sent via templates. **Problem solved:** Documents sent via WhatsApp templates always appeared as "untitled" because Chatwoot didn't process the `filename` field required by the WhatsApp API. **Solution:** Added support for the `media_name` parameter that maps to the WhatsApp API's `filename` field. ## Type of change - [x] New feature (non-breaking change which adds functionality) - [x] This change requires a documentation update ## How Has This Been Tested? Created and executed **7 comprehensive test scenarios**: 1. ✅ Document without `media_name` (backward compatibility) 2. ✅ Document with valid `media_name` 3. ✅ Document with blank `media_name` 4. ✅ Document with null `media_name` 5. ✅ Image with `media_name` (ignored as expected) 6. ✅ Video with `media_name` (ignored as expected) 7. ✅ Blank URL (returns nil appropriately) **All tests passed** and confirmed **100% backward compatibility**. ## Technical Implementation **Backend Changes:** - `PopulateTemplateParametersService`: Added `media_name` parameter support - `TemplateProcessorService`: Pass `media_name` to parameter builder - `WhatsappCloudService`: Updated documentation with `media_name` example **Frontend Changes:** - `WhatsAppTemplateParser.vue`: Added UI field for document filename input - `templateHelper.js`: Include `media_name` for document templates - `whatsappTemplates.json`: Added translation key for document name placeholder **Key Features:** - 🔄 **100% Backward Compatible** - Existing templates continue working - 📝 **Document Filename Support** - Users can specify custom filenames - 🎯 **Document-Only Feature** - Only affects document media types - ✅ **Comprehensive Testing** - All edge cases covered ## Expected Behavior **Before:** ```ruby # All documents appear as "untitled" { type: 'document', document: { link: 'https://example.com/document.pdf' } } ``` **After:** ```ruby # With media_name - displays custom filename { type: 'document', document: { link: 'https://example.com/document.pdf', filename: 'Invoice_2025.pdf' } } # Without media_name - works as before { type: 'document', document: { link: 'https://example.com/document.pdf' } } ``` ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
48 lines
1.8 KiB
JSON
48 lines
1.8 KiB
JSON
{
|
|
"WHATSAPP_TEMPLATES": {
|
|
"MODAL": {
|
|
"TITLE": "Whatsapp Templates",
|
|
"SUBTITLE": "Select the whatsapp template you want to send",
|
|
"TEMPLATE_SELECTED_SUBTITLE": "Configure template: {templateName}"
|
|
},
|
|
"PICKER": {
|
|
"SEARCH_PLACEHOLDER": "Search Templates",
|
|
"NO_TEMPLATES_FOUND": "No templates found for",
|
|
"HEADER": "Header",
|
|
"BODY": "Body",
|
|
"FOOTER": "Footer",
|
|
"BUTTONS": "Buttons",
|
|
"CATEGORY": "Category",
|
|
"MEDIA_CONTENT": "Media Content",
|
|
"MEDIA_CONTENT_FALLBACK": "media content",
|
|
"NO_TEMPLATES_AVAILABLE": "No WhatsApp templates available. Click refresh to sync templates from WhatsApp.",
|
|
"REFRESH_BUTTON": "Refresh templates",
|
|
"REFRESH_SUCCESS": "Templates refresh initiated. It may take a couple of minutes to update.",
|
|
"REFRESH_ERROR": "Failed to refresh templates. Please try again.",
|
|
"LABELS": {
|
|
"LANGUAGE": "Language",
|
|
"TEMPLATE_BODY": "Template Body",
|
|
"CATEGORY": "Category"
|
|
}
|
|
},
|
|
"PARSER": {
|
|
"VARIABLES_LABEL": "Variables",
|
|
"LANGUAGE": "Language",
|
|
"CATEGORY": "Category",
|
|
"VARIABLE_PLACEHOLDER": "Enter {variable} value",
|
|
"GO_BACK_LABEL": "Go Back",
|
|
"SEND_MESSAGE_LABEL": "Send Message",
|
|
"FORM_ERROR_MESSAGE": "Please fill all variables before sending",
|
|
"MEDIA_HEADER_LABEL": "{type} Header",
|
|
"OTP_CODE": "Enter 4-8 digit OTP",
|
|
"EXPIRY_MINUTES": "Enter expiry minutes",
|
|
"BUTTON_PARAMETERS": "Button Parameters",
|
|
"BUTTON_LABEL": "Button {index}",
|
|
"COUPON_CODE": "Enter coupon code (max 15 chars)",
|
|
"MEDIA_URL_LABEL": "Enter {type} URL",
|
|
"DOCUMENT_NAME_PLACEHOLDER": "Enter document filename (e.g., Invoice_2025.pdf)",
|
|
"BUTTON_PARAMETER": "Enter button parameter"
|
|
}
|
|
}
|
|
}
|