diff --git a/packages/node/src/lib/events/events.interface.ts b/packages/node/src/lib/events/events.interface.ts index 174facc0532..8236216350e 100644 --- a/packages/node/src/lib/events/events.interface.ts +++ b/packages/node/src/lib/events/events.interface.ts @@ -66,6 +66,8 @@ export type ITriggerOverrides = { [key in 'sms']?: ITriggerOverrideSMS; } & { [key in SmsProviderIdEnum]?: ITriggerOverrideSMS; +} & { + [key in 'whatsapp']?: IWhatsappOverrides; }; export type ITriggerOverrideDelayAction = { @@ -154,6 +156,103 @@ export type ITriggerOverrideExpo = { mutableContent?: boolean; }; +export type IWhatsappOverrides = { + template?: { + name: string; + language: { + code: string; + }; + components?: IWhatsappComponent[]; + }; +} & { + [key in + | 'audio' + | 'document' + | 'image' + | 'sticker' + | 'video']?: IWhatsappMedia; +} & { + interactive?: { + type: + | 'button' + | 'catalog_message' + | 'list' + | 'product' + | 'product_list' + | 'flow'; + action: { + button?: string; + buttons?: { + type: 'reply'; + title: string; + id: string; + }[]; + catalog_id?: string; + product_retailer_id?: string; + sections?: IWhatsappSections[]; + mode?: 'draft' | 'published'; + flow_message_version?: '3'; + flow_token?: string; + flow_id?: string; + flow_cta?: string; + flow_action?: string; + flow_action_payload?: { + screen: string; + data?: { + [key: string]: string; + }; + }; + }; + header?: { + type: 'text' | 'image' | 'video' | 'document'; + document?: IWhatsappMedia; + image?: IWhatsappMedia; + text?: string; + video?: IWhatsappMedia; + }; + body?: { + text: string; + }; + footer?: { + text: string; + }; + }; +}; + +export type IWhatsappMedia = { + id?: string; + link?: string; + caption?: string; + filename?: string; +}; + +export interface IWhatsappSections { + product_items?: { product_retailer_id: string }[]; + rows?: { id: string; title: string; description: string }[]; + title?: string; +} + +export interface IWhatsappComponent { + type: 'body' | 'header' | 'button'; + sub_type?: 'quick_reply' | 'url' | 'catalog'; + parameters: { + type: 'currency' | 'date_time' | 'document' | 'image' | 'text' | 'video'; + text?: string; + currency?: { + fallback_value: string; + code: string; + amount_1000: number; + }; + date_time?: { + fallback_value: string; + }; + image?: IWhatsappMedia; + document?: IWhatsappMedia; + video?: IWhatsappMedia; + }[]; + index?: number; +} + export interface IBulkEvents extends ITriggerPayloadOptions { name: string; } diff --git a/packages/providers/src/lib/whatsapp-business/consts/whatsapp-business.enum.ts b/packages/providers/src/lib/whatsapp-business/consts/whatsapp-business.enum.ts index 21ae0c32d34..4b6e3933916 100644 --- a/packages/providers/src/lib/whatsapp-business/consts/whatsapp-business.enum.ts +++ b/packages/providers/src/lib/whatsapp-business/consts/whatsapp-business.enum.ts @@ -1,4 +1,12 @@ export enum WhatsAppMessageTypeEnum { TEMPLATE = 'template', TEXT = 'text', + INTERACTIVE = 'interactive', + IMAGE = 'image', + DOCUMENT = 'document', + VIDEO = 'video', + AUDIO = 'audio', + LOCATION = 'location', + CONTACTS = 'contacts', + STICKER = 'sticker', }