diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index 51cae8679..683559b8e 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -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", diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AccountHealth.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AccountHealth.vue index 026c8ef69..7c9f4fbe3 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AccountHealth.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/components/AccountHealth.vue @@ -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'); } }; diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/CustomerSatisfactionPage.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/CustomerSatisfactionPage.vue index 9e91f9642..09a5a8890 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/CustomerSatisfactionPage.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/settingsPage/CustomerSatisfactionPage.vue @@ -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 }} + + {{ $t('INBOX_MGMT.CSAT.TEMPLATE_STATUS.VIEW_TEMPLATE') }} + diff --git a/app/javascript/shared/constants/links.js b/app/javascript/shared/constants/links.js index 4797cec4e..fa3a22222 100644 --- a/app/javascript/shared/constants/links.js +++ b/app/javascript/shared/constants/links.js @@ -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'; diff --git a/app/services/csat_template_management_service.rb b/app/services/csat_template_management_service.rb index 064804082..774d508be 100644 --- a/app/services/csat_template_management_service.rb +++ b/app/services/csat_template_management_service.rb @@ -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 { diff --git a/app/services/whatsapp/csat_template_service.rb b/app/services/whatsapp/csat_template_service.rb index 9bdbef8ca..9dc057a10 100644 --- a/app/services/whatsapp/csat_template_service.rb +++ b/app/services/whatsapp/csat_template_service.rb @@ -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)