feat: WhatsApp enhanced templates front end changes (#12117)
Part of the https://github.com/chatwoot/chatwoot/pull/11997 Co-authored-by: Sojan Jose <sojan@pepalo.com> Co-authored-by: iamsivin <iamsivin@gmail.com>
This commit is contained in:
@@ -44,15 +44,52 @@ export const getters = {
|
||||
const messagesTemplates =
|
||||
whatsAppMessageTemplates || apiInboxMessageTemplates;
|
||||
|
||||
// filtering out the whatsapp templates with media
|
||||
if (messagesTemplates instanceof Array) {
|
||||
return messagesTemplates.filter(template => {
|
||||
return !template.components.some(
|
||||
i => i.format === 'IMAGE' || i.format === 'VIDEO'
|
||||
);
|
||||
});
|
||||
return messagesTemplates;
|
||||
},
|
||||
getFilteredWhatsAppTemplates: $state => inboxId => {
|
||||
const [inbox] = $state.records.filter(
|
||||
record => record.id === Number(inboxId)
|
||||
);
|
||||
|
||||
const {
|
||||
message_templates: whatsAppMessageTemplates,
|
||||
additional_attributes: additionalAttributes,
|
||||
} = inbox || {};
|
||||
|
||||
const { message_templates: apiInboxMessageTemplates } =
|
||||
additionalAttributes || {};
|
||||
const templates = whatsAppMessageTemplates || apiInboxMessageTemplates;
|
||||
|
||||
if (!templates || !Array.isArray(templates)) {
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
|
||||
return templates.filter(template => {
|
||||
// Ensure template has required properties
|
||||
if (!template || !template.status || !template.components) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only show approved templates
|
||||
if (template.status.toLowerCase() !== 'approved') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter out interactive templates (LIST, PRODUCT, CATALOG), location templates, and call permission templates
|
||||
const hasUnsupportedComponents = template.components.some(
|
||||
component =>
|
||||
['LIST', 'PRODUCT', 'CATALOG', 'CALL_PERMISSION_REQUEST'].includes(
|
||||
component.type
|
||||
) ||
|
||||
(component.type === 'HEADER' && component.format === 'LOCATION')
|
||||
);
|
||||
|
||||
if (hasUnsupportedComponents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
},
|
||||
getNewConversationInboxes($state) {
|
||||
return $state.records.filter(inbox => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { getters } from '../../inboxes';
|
||||
import inboxList from './fixtures';
|
||||
import { templates } from './templateFixtures';
|
||||
|
||||
describe('#getters', () => {
|
||||
it('getInboxes', () => {
|
||||
@@ -93,4 +94,269 @@ describe('#getters', () => {
|
||||
provider: 'default',
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFilteredWhatsAppTemplates', () => {
|
||||
it('returns empty array when inbox not found', () => {
|
||||
const state = { records: [] };
|
||||
expect(getters.getFilteredWhatsAppTemplates(state)(999)).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty array when templates is null or undefined', () => {
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: null,
|
||||
additional_attributes: { message_templates: undefined },
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(getters.getFilteredWhatsAppTemplates(state)(1)).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty array when templates is not an array', () => {
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: 'invalid',
|
||||
additional_attributes: {},
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(getters.getFilteredWhatsAppTemplates(state)(1)).toEqual([]);
|
||||
});
|
||||
|
||||
it('filters out templates without required properties', () => {
|
||||
const invalidTemplates = [
|
||||
{ name: 'incomplete_template' }, // missing status and components
|
||||
{ status: 'approved' }, // missing name and components
|
||||
{ name: 'another_incomplete', status: 'approved' }, // missing components
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: invalidTemplates,
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(getters.getFilteredWhatsAppTemplates(state)(1)).toEqual([]);
|
||||
});
|
||||
|
||||
it('filters out non-approved templates', () => {
|
||||
const mixedStatusTemplates = [
|
||||
{
|
||||
name: 'pending_template',
|
||||
status: 'pending',
|
||||
components: [{ type: 'BODY', text: 'Test' }],
|
||||
},
|
||||
{
|
||||
name: 'rejected_template',
|
||||
status: 'rejected',
|
||||
components: [{ type: 'BODY', text: 'Test' }],
|
||||
},
|
||||
{
|
||||
name: 'approved_template',
|
||||
status: 'approved',
|
||||
components: [{ type: 'BODY', text: 'Test' }],
|
||||
},
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: mixedStatusTemplates,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('approved_template');
|
||||
});
|
||||
|
||||
it('filters out interactive templates (LIST, PRODUCT, CATALOG)', () => {
|
||||
const interactiveTemplates = [
|
||||
{
|
||||
name: 'list_template',
|
||||
status: 'approved',
|
||||
components: [
|
||||
{ type: 'BODY', text: 'Choose an option' },
|
||||
{ type: 'LIST', sections: [] },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'product_template',
|
||||
status: 'approved',
|
||||
components: [
|
||||
{ type: 'BODY', text: 'Product info' },
|
||||
{ type: 'PRODUCT', catalog_id: '123' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'catalog_template',
|
||||
status: 'approved',
|
||||
components: [
|
||||
{ type: 'BODY', text: 'Catalog' },
|
||||
{ type: 'CATALOG', thumbnail_product_retailer_id: '123' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'regular_template',
|
||||
status: 'approved',
|
||||
components: [{ type: 'BODY', text: 'Regular message' }],
|
||||
},
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: interactiveTemplates,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('regular_template');
|
||||
});
|
||||
|
||||
it('filters out location templates', () => {
|
||||
const locationTemplates = [
|
||||
{
|
||||
name: 'location_template',
|
||||
status: 'approved',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'LOCATION' },
|
||||
{ type: 'BODY', text: 'Location message' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'regular_template',
|
||||
status: 'approved',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'TEXT', text: 'Header' },
|
||||
{ type: 'BODY', text: 'Regular message' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: locationTemplates,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('regular_template');
|
||||
});
|
||||
|
||||
it('returns valid templates from fixture data', () => {
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: templates,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
|
||||
// All templates in fixtures should be approved and valid
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
||||
// Verify all returned templates are approved
|
||||
result.forEach(template => {
|
||||
expect(template.status).toBe('approved');
|
||||
expect(template.components).toBeDefined();
|
||||
expect(Array.isArray(template.components)).toBe(true);
|
||||
});
|
||||
|
||||
// Verify specific templates from fixtures are included
|
||||
const templateNames = result.map(t => t.name);
|
||||
expect(templateNames).toContain('sample_flight_confirmation');
|
||||
expect(templateNames).toContain('sample_issue_resolution');
|
||||
expect(templateNames).toContain('sample_shipping_confirmation');
|
||||
expect(templateNames).toContain('no_variable_template');
|
||||
expect(templateNames).toContain('order_confirmation');
|
||||
});
|
||||
|
||||
it('prioritizes message_templates over additional_attributes.message_templates', () => {
|
||||
const primaryTemplates = [
|
||||
{
|
||||
name: 'primary_template',
|
||||
status: 'approved',
|
||||
components: [{ type: 'BODY', text: 'Primary' }],
|
||||
},
|
||||
];
|
||||
|
||||
const fallbackTemplates = [
|
||||
{
|
||||
name: 'fallback_template',
|
||||
status: 'approved',
|
||||
components: [{ type: 'BODY', text: 'Fallback' }],
|
||||
},
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: primaryTemplates,
|
||||
additional_attributes: {
|
||||
message_templates: fallbackTemplates,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('primary_template');
|
||||
});
|
||||
|
||||
it('falls back to additional_attributes.message_templates when message_templates is null', () => {
|
||||
const fallbackTemplates = [
|
||||
{
|
||||
name: 'fallback_template',
|
||||
status: 'approved',
|
||||
components: [{ type: 'BODY', text: 'Fallback' }],
|
||||
},
|
||||
];
|
||||
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_type: 'Channel::Whatsapp',
|
||||
message_templates: null,
|
||||
additional_attributes: {
|
||||
message_templates: fallbackTemplates,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getters.getFilteredWhatsAppTemplates(state)(1);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].name).toBe('fallback_template');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,544 @@
|
||||
export const templates = [
|
||||
{
|
||||
name: 'sample_flight_confirmation',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'pt_BR',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'DOCUMENT' },
|
||||
{
|
||||
text: 'Esta é a sua confirmação de voo para {{1}}-{{2}} em {{3}}.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Esta mensagem é de uma empresa não verificada.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_issue_resolution',
|
||||
status: 'approved',
|
||||
category: 'ISSUE_RESOLUTION',
|
||||
language: 'pt_BR',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Oi, {{1}}. Nós conseguimos resolver o problema que você estava enfrentando?',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Esta mensagem é de uma empresa não verificada.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{ text: 'Sim', type: 'QUICK_REPLY' },
|
||||
{ text: 'Não', type: 'QUICK_REPLY' },
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_issue_resolution',
|
||||
status: 'approved',
|
||||
category: 'ISSUE_RESOLUTION',
|
||||
language: 'es',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Hola, {{1}}. ¿Pudiste solucionar el problema que tenías?',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Este mensaje proviene de un negocio no verificado.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{ text: 'Sí', type: 'QUICK_REPLY' },
|
||||
{ text: 'No', type: 'QUICK_REPLY' },
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_issue_resolution',
|
||||
status: 'approved',
|
||||
category: 'ISSUE_RESOLUTION',
|
||||
language: 'id',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Halo {{1}}, apakah kami bisa mengatasi masalah yang sedang Anda hadapi?',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Pesan ini berasal dari bisnis yang tidak terverifikasi.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{ text: 'Ya', type: 'QUICK_REPLY' },
|
||||
{ text: 'Tidak', type: 'QUICK_REPLY' },
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_shipping_confirmation',
|
||||
status: 'approved',
|
||||
category: 'SHIPPING_UPDATE',
|
||||
language: 'pt_BR',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Seu pacote foi enviado. Ele será entregue em {{1}} dias úteis.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Esta mensagem é de uma empresa não verificada.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_shipping_confirmation',
|
||||
status: 'approved',
|
||||
category: 'SHIPPING_UPDATE',
|
||||
language: 'id',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Paket Anda sudah dikirim. Paket akan sampai dalam {{1}} hari kerja.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Pesan ini berasal dari bisnis yang tidak terverifikasi.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_shipping_confirmation',
|
||||
status: 'approved',
|
||||
category: 'SHIPPING_UPDATE',
|
||||
language: 'es',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'ó tu paquete. La entrega se realizará en {{1}} dí.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Este mensaje proviene de un negocio no verificado.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_flight_confirmation',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'id',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'DOCUMENT' },
|
||||
{
|
||||
text: 'Ini merupakan konfirmasi penerbangan Anda untuk {{1}}-{{2}} di {{3}}.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Pesan ini berasal dari bisnis yang tidak terverifikasi.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_issue_resolution',
|
||||
status: 'approved',
|
||||
category: 'ISSUE_RESOLUTION',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Hi {{1}}, were we able to solve the issue that you were facing?',
|
||||
type: 'BODY',
|
||||
},
|
||||
{ text: 'This message is from an unverified business.', type: 'FOOTER' },
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{ text: 'Yes', type: 'QUICK_REPLY' },
|
||||
{ text: 'No', type: 'QUICK_REPLY' },
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_flight_confirmation',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'es',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'DOCUMENT' },
|
||||
{
|
||||
text: 'Confirmamos tu vuelo a {{1}}-{{2}} para el {{3}}.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Este mensaje proviene de un negocio no verificado.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_flight_confirmation',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{ type: 'HEADER', format: 'DOCUMENT' },
|
||||
{
|
||||
text: 'This is your flight confirmation for {{1}}-{{2}} on {{3}}.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{ text: 'This message is from an unverified business.', type: 'FOOTER' },
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'sample_shipping_confirmation',
|
||||
status: 'approved',
|
||||
category: 'SHIPPING_UPDATE',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Your package has been shipped. It will be delivered in {{1}} business days.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{ text: 'This message is from an unverified business.', type: 'FOOTER' },
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'no_variable_template',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'pt_BR',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
type: 'HEADER',
|
||||
format: 'DOCUMENT',
|
||||
},
|
||||
{
|
||||
text: 'This is a test whatsapp template',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Esta mensagem é de uma empresa não verificada.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'order_confirmation',
|
||||
status: 'approved',
|
||||
category: 'TICKET_UPDATE',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
type: 'HEADER',
|
||||
format: 'IMAGE',
|
||||
example: {
|
||||
header_handle: ['https://example.com/shoes.jpg'],
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Hi your order {{1}} is confirmed. Please wait for further updates',
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'technician_visit',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Technician visit',
|
||||
type: 'HEADER',
|
||||
format: 'TEXT',
|
||||
},
|
||||
{
|
||||
text: "Hi {{1}}, we're scheduling a technician visit to {{2}} on {{3}} between {{4}} and {{5}}. Please confirm if this time slot works for you.",
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Confirm',
|
||||
type: 'QUICK_REPLY',
|
||||
},
|
||||
{
|
||||
text: 'Reschedule',
|
||||
type: 'QUICK_REPLY',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'event_invitation_static',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: "You're invited to {{event_name}} at {{location}}, Join us for an amazing experience!",
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{
|
||||
url: 'https://events.example.com/register',
|
||||
text: 'Visit website',
|
||||
type: 'URL',
|
||||
},
|
||||
{
|
||||
url: 'https://maps.app.goo.gl/YoWAzRj1GDuxs6qz8',
|
||||
text: 'Get Directions',
|
||||
type: 'URL',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'purchase_receipt',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
type: 'HEADER',
|
||||
format: 'DOCUMENT',
|
||||
},
|
||||
{
|
||||
text: 'Thank you for using your {{1}} card at {{2}}. Your {{3}} is attached as a PDF.',
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'discount_coupon',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: '🎉 Special offer for you! Get {{discount_percentage}}% off your next purchase. Use the code below at checkout',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Copy offer code',
|
||||
type: 'COPY_CODE',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'support_callback',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Hello {{name}}, our support team will call you regarding ticket # {{ticket_id}}.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Call Support',
|
||||
type: 'PHONE_NUMBER',
|
||||
phone_number: '+16506677566',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'training_video',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
type: 'HEADER',
|
||||
format: 'VIDEO',
|
||||
},
|
||||
{
|
||||
text: "Hi {{name}}, here's your training video. Please watch by{{date}}.",
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'product_launch',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
type: 'HEADER',
|
||||
format: 'IMAGE',
|
||||
},
|
||||
{
|
||||
text: 'New arrival! Our stunning coat now available in {{color}} color.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'Free shipping on orders over $100. Limited time offer.',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'greet',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Hey {{customer_name}} how may I help you?',
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'hello_world',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Hello World',
|
||||
type: 'HEADER',
|
||||
format: 'TEXT',
|
||||
},
|
||||
{
|
||||
text: 'Welcome and congratulations!! This message demonstrates your ability to send a WhatsApp message notification from the Cloud API, hosted by Meta. Thank you for taking the time to test with us.',
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
text: 'WhatsApp Business Platform sample message',
|
||||
type: 'FOOTER',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'feedback_request',
|
||||
status: 'approved',
|
||||
category: 'MARKETING',
|
||||
language: 'en',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: "Hey {{name}}, how was your experience with Puma? We'd love your feedback!",
|
||||
type: 'BODY',
|
||||
},
|
||||
{
|
||||
type: 'BUTTONS',
|
||||
buttons: [
|
||||
{
|
||||
url: 'https://feedback.example.com/survey',
|
||||
text: 'Leave Feedback',
|
||||
type: 'URL',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'address_update',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: 'Address update',
|
||||
type: 'HEADER',
|
||||
format: 'TEXT',
|
||||
},
|
||||
{
|
||||
text: 'Hi {{1}}, your delivery address has been successfully updated to {{2}}. Contact {{3}} for any inquiries.',
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
{
|
||||
name: 'delivery_confirmation',
|
||||
status: 'approved',
|
||||
category: 'UTILITY',
|
||||
language: 'en_US',
|
||||
namespace: 'ed41a221_133a_4558_a1d6_192960e3aee9',
|
||||
components: [
|
||||
{
|
||||
text: '{{1}}, your order was successfully delivered on {{2}}.\n\nThank you for your purchase.\n',
|
||||
type: 'BODY',
|
||||
},
|
||||
],
|
||||
rejected_reason: 'NONE',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user