/** * Template language configuration */ export interface TemplateLanguage { /** Language code (e.g., "en", "en_GB", "hi") */ code: string; /** Policy type */ policy: "deterministic"; } /** * Text header component */ export interface TextHeader { type: "text"; value: string; } /** * Image header component */ export interface ImageHeader { type: "image"; /** URL of the image */ value: string; } /** * Video header component */ export interface VideoHeader { type: "video"; /** URL of the video */ value: string; } /** * Document header component */ export interface DocumentHeader { type: "document"; /** URL of the document */ value: string; /** Filename to display */ filename: string; } /** * Location header data */ export interface LocationHeaderData { latitude: string; longitude: string; name: string; address: string; } /** * Location component part */ export interface LocationComponent { type: "location"; value: string; } export type HeaderComponent = TextHeader | ImageHeader | VideoHeader | DocumentHeader; /** * Text body component for template variables */ export interface BodyComponent { type: "text"; value: string; } /** * URL button component */ export interface UrlButton { type: "text"; subtype: "url"; /** URL variable value */ value: string; } /** * Copy code button component */ export interface CopyCodeButton { type: "coupon_code"; subtype: "COPY_CODE"; coupon_code: string; } /** * Catalog button component */ export interface CatalogButton { type: "action"; subtype: "CATALOG"; /** Product retailer ID */ value: string; } /** * Product item for multi-product message */ export interface ProductItem { product_retailer_id: string; } /** * Product section for multi-product message */ export interface ProductSection { title: string; product_items: ProductItem[]; } /** * Multi-product message button */ export interface MultiProductButton { type: "action"; subtype: "MPM"; value: { thumbnail_product_retailer_id: string; sections: ProductSection[]; }; } export type ButtonComponent = UrlButton | CopyCodeButton | CatalogButton | MultiProductButton; /** * All possible template components */ export interface TemplateComponents { header_1?: HeaderComponent; header_1_latitude?: LocationComponent; header_1_longitude?: LocationComponent; header_1_name?: LocationComponent; header_1_address?: LocationComponent; body_1?: BodyComponent; body_2?: BodyComponent; body_3?: BodyComponent; body_4?: BodyComponent; body_5?: BodyComponent; body_6?: BodyComponent; body_7?: BodyComponent; body_8?: BodyComponent; body_9?: BodyComponent; button_1?: ButtonComponent; button_2?: ButtonComponent; card_0_header_1?: ImageHeader | VideoHeader; card_1_header_1?: ImageHeader | VideoHeader; card_2_header_1?: ImageHeader | VideoHeader; card_3_header_1?: ImageHeader | VideoHeader; card_4_header_1?: ImageHeader | VideoHeader; [key: string]: unknown; } /** * Recipient with their specific template components */ export interface ToAndComponents { /** Array of phone numbers with country code */ to: string[]; /** Template components for this recipient */ components: TemplateComponents; } /** * WhatsApp template configuration */ export interface WhatsAppTemplate { /** Template name from MSG91 dashboard */ name: string; /** Language configuration */ language: TemplateLanguage; /** Namespace (usually null) */ namespace: string | null; /** Recipients and their components */ to_and_components: ToAndComponents[]; } /** * WhatsApp message payload */ export interface WhatsAppPayload { messaging_product: "whatsapp"; type: "template"; template: WhatsAppTemplate; } /** * Simplified parameters for sending a WhatsApp message */ export interface SendWhatsAppMessageParams { /** Your integrated WhatsApp number */ integratedNumber: string; /** Template name from MSG91 dashboard */ templateName: string; /** Language code (default: "en") */ languageCode?: string; /** Template namespace from MSG91 dashboard */ namespace?: string; /** Recipients with their components */ recipients: Array<{ /** Phone number(s) with country code */ to: string | string[]; /** Template components for this recipient */ components?: TemplateComponents; }>; } /** * Raw WhatsApp message request body */ export interface WhatsAppMessageRequest { integrated_number: string; content_type: "template"; payload: WhatsAppPayload; } /** * Response from WhatsApp send API */ export interface SendWhatsAppMessageResponse { type: "success" | "error"; message: string; request_id?: string; } /** * Fluent builder interface for WhatsApp messages */ export interface WhatsAppMessageBuilder { /** Set the integrated WhatsApp number */ setIntegratedNumber(number: string): this; /** Set the template name and language */ setTemplate(name: string, languageCode?: string): this; /** Set the template namespace */ setNamespace(namespace: string): this; /** Add a recipient with optional components */ addRecipient(to: string | string[], components?: TemplateComponents): this; /** Set text header for current recipient */ withTextHeader(value: string): this; /** Set image header for current recipient */ withImageHeader(url: string): this; /** Set video header for current recipient */ withVideoHeader(url: string): this; /** Set document header for current recipient */ withDocumentHeader(url: string, filename: string): this; /** Set location header for current recipient */ withLocationHeader(location: LocationHeaderData): this; /** Set body variable at index */ withBodyVariable(index: number, value: string): this; /** Set URL button at index */ withUrlButton(index: number, urlVariable: string): this; /** Set copy code button at index */ withCopyCodeButton(index: number, couponCode: string): this; /** Set carousel card header */ withCarouselCard(cardIndex: number, mediaType: "image" | "video", url: string): this; /** Build the final request */ build(): WhatsAppMessageRequest; } //# sourceMappingURL=types.d.ts.map