Compare commits

...
Author SHA1 Message Date
Muhsin 28778e3ae2 feat: add link to view CSAT template in WhatsApp Manager 2026-01-27 11:34:57 +04:00
6 changed files with 35 additions and 6 deletions
@@ -825,7 +825,8 @@
"PENDING": "Pending WhatsApp approval",
"REJECTED": "Meta rejected the template",
"DEFAULT": "Needs WhatsApp approval",
"NOT_FOUND": "The template does not exist in the Meta platform."
"NOT_FOUND": "The template does not exist in the Meta platform.",
"VIEW_TEMPLATE": "View in WhatsApp Manager"
},
"TEMPLATE_CREATION": {
"SUCCESS_MESSAGE": "WhatsApp template created successfully and sent for approval",
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import ButtonV4 from 'next/button/Button.vue';
import Icon from 'dashboard/components-next/icon/Icon.vue';
import { META_BUSINESS_URL } from 'shared/constants/links';
const props = defineProps({
healthData: {
@@ -109,12 +110,11 @@ const handleGoToSettings = () => {
if (businessId) {
// WhatsApp Business Manager URL with specific business ID and phone numbers tab
const whatsappBusinessUrl = `https://business.facebook.com/latest/whatsapp_manager/phone_numbers/?business_id=${businessId}&tab=phone-numbers`;
const whatsappBusinessUrl = `${META_BUSINESS_URL}/latest/whatsapp_manager/phone_numbers/?business_id=${businessId}&tab=phone-numbers`;
window.open(whatsappBusinessUrl, '_blank');
} else {
// Fallback to general WhatsApp Business Manager if business_id is not available
const fallbackUrl = 'https://business.facebook.com/';
window.open(fallbackUrl, '_blank');
window.open(META_BUSINESS_URL, '_blank');
}
};
@@ -5,6 +5,7 @@ import { useAlert } from 'dashboard/composables';
import { useStore, useMapGetter } from 'dashboard/composables/store';
import { useInbox } from 'dashboard/composables/useInbox';
import { CSAT_DISPLAY_TYPES } from 'shared/constants/messages';
import { META_BUSINESS_URL } from 'shared/constants/links';
import Icon from 'dashboard/components-next/icon/Icon.vue';
import WithLabel from 'v3/components/Form/WithLabel.vue';
@@ -91,6 +92,21 @@ const shouldShowTemplateStatus = computed(
() => templateStatus.value && !templateLoading.value
);
const templateDetailsUrl = computed(() => {
if (
!isAWhatsAppChannel.value ||
!templateStatus.value?.template_exists ||
!templateStatus.value?.template_id ||
!templateStatus.value?.business_account_id
) {
return null;
}
const businessId = templateStatus.value.business_account_id;
const templateId = templateStatus.value.template_id;
return `${META_BUSINESS_URL}/latest/whatsapp_manager/template_details?business_id=${businessId}&id=${templateId}`;
});
const templateApprovalStatus = computed(() => {
const statusMap = {
APPROVED: {
@@ -488,6 +504,15 @@ const handleConfirmTemplateUpdate = async () => {
>
{{ templateApprovalStatus.text }}
</span>
<a
v-if="templateDetailsUrl"
:href="templateDetailsUrl"
target="_blank"
rel="noopener noreferrer"
class="text-sm font-medium text-n-blue-text hover:underline"
>
{{ $t('INBOX_MGMT.CSAT.TEMPLATE_STATUS.VIEW_TEMPLATE') }}
</a>
</div>
</div>
+2
View File
@@ -9,3 +9,5 @@ export const REPLY_POLICY = {
};
export const CHANGELOG_API_URL = 'https://hub.2.chatwoot.com/changelogs';
export const META_BUSINESS_URL = 'https://business.facebook.com';
@@ -136,7 +136,8 @@ class CsatTemplateManagementService
template_exists: true,
template_name: template_name,
status: status_result[:template][:status],
template_id: status_result[:template][:id]
template_id: status_result[:template][:id],
business_account_id: @inbox.channel.provider_config['business_account_id']
}
else
{
@@ -2,7 +2,7 @@ class Whatsapp::CsatTemplateService
DEFAULT_BUTTON_TEXT = 'Please rate us'.freeze
DEFAULT_LANGUAGE = 'en'.freeze
WHATSAPP_API_VERSION = 'v14.0'.freeze
TEMPLATE_CATEGORY = 'MARKETING'.freeze
TEMPLATE_CATEGORY = 'UTILITY'.freeze
TEMPLATE_STATUS_PENDING = 'PENDING'.freeze
def initialize(whatsapp_channel)