import "github.com/gTahidi/wapi.go/pkg/components"type AddressType stringconst (
HomeAddress AddressType = "HOME"
WorkAddress AddressType = "WORK"
)const (
HomeUrl AddressType = "HOME"
WorkUrl AddressType = "WORK"
)ApiCompatibleJsonConverterConfigs represents the configuration for converting to JSON.
type ApiCompatibleJsonConverterConfigs struct {
ReplyToMessageId string
SendToPhoneNumber string
}AudioMessage represents an audio message.
type AudioMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}func NewAudioMessage(params AudioMessageConfigs) (*AudioMessage, error)NewAudioMessage creates a new AudioMessage object.
func (audio *AudioMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the AudioMessage object to JSON.
AudioMessageApiPayload represents the payload for an audio message API request.
type AudioMessageApiPayload struct {
BaseMessagePayload
Audio AudioMessage `json:"audio" validate:"required"`
}AudioMessageConfigs is an alias for AudioMessage.
type AudioMessageConfigs = AudioMessageBaseMessage is an interface for sending messages.
type BaseMessage interface {
ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)
}BaseMessagePayload represents the base payload to send messages.
type BaseMessagePayload struct {
Context *Context `json:"context,omitempty"`
To string `json:"to"`
Type MessageType `json:"type"`
MessagingProduct string `json:"messaging_product"`
RecipientType string `json:"recipient_type"`
}func NewBaseMessagePayload(to string, messageType MessageType) BaseMessagePayloadNewBaseMessagePayload creates a new instance of BaseMessagePayload.
ProductMessage represents a product message.
type CatalogMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Action CatalogMessageAction `json:"action" validate:"required"`
Body CatalogMessageBody `json:"body" validate:"required"`
Footer *CatalogMessageFooter `json:"footer,omitempty"`
Header *CatalogMessageHeader `json:"header,omitempty"`
}func NewCatalogMessage(name, thumbnailProductRetailerId string) (*CatalogMessage, error)func (m *CatalogMessage) SetBody(text string)func (m *CatalogMessage) SetFooter(text string)func (m *CatalogMessage) SetHeader(text string)func (m *CatalogMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the product message to JSON with the given configurations.
type CatalogMessageAction struct {
Name string `json:"name" validate:"required"`
Parameters CatalogMessageActionParameter `json:"parameters,omitempty"`
}type CatalogMessageActionParameter struct {
ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id" validate:"required"`
}ProductMessageApiPayload represents the API payload for a product message.
type CatalogMessageApiPayload struct {
BaseMessagePayload
Interactive CatalogMessage `json:"interactive" validate:"required"`
}type CatalogMessageBody struct {
Text string `json:"text" validate:"required"`
}type CatalogMessageFooter struct {
Text string `json:"text" validate:"required"`
}type CatalogMessageHeader struct {
Text string `json:"text" validate:"required"`
}type Contact struct {
Name ContactName `json:"name" validate:"required"`
Org ContactOrg `json:"org,omitempty"`
Addresses []ContactAddress `json:"addresses,omitempty"`
Urls []ContactUrl `json:"urls,omitempty"`
Emails []ContactEmail `json:"emails,omitempty"`
Phones []ContactPhone `json:"phones,omitempty"`
Birthday string `json:"birthday,omitempty"`
}func NewContact(name ContactName) *Contactfunc (contact *Contact) AddEmail(params ContactEmail)func (contact *Contact) AddPhone(params ContactPhone)func (contact *Contact) AddUrl(params ContactUrl)func (contact *Contact) SetBirthday(params string)! TODO: add regex check here in the params
func (contact *Contact) SetFirstName(firstName string)func (contact *Contact) SetLastName(lastName string)func (contact *Contact) SetMiddleName(middleName string)func (contact *Contact) SetOrg(params ContactOrg)type ContactAddress struct {
Street string `json:"street,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Zip string `json:"zip,omitempty"`
Country string `json:"country,omitempty"`
CountryCode string `json:"countryCode,omitempty"`
Type AddressType `json:"type" validate:"required"`
}type ContactEmail struct {
Email string `json:"email,omitempty"`
Type EmailType `json:"type,omitempty"`
}type ContactMessage struct {
Contacts []Contact `json:"contacts" validate:"required"`
}func NewContactMessage(configs []Contact) (*ContactMessage, error)func (contact *ContactMessage) AddContact(params Contact)func (m *ContactMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)type ContactMessageApiPayload struct {
BaseMessagePayload
Contacts []Contact `json:"contacts" validate:"required"`
}type ContactMessageConfigs struct {
Name string `json:"name" validate:"required"`
}type ContactName struct {
FormattedName string `json:"formatted_name" validate:"required"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
MiddleName string `json:"middle_name,omitempty"`
Suffix string `json:"suffix,omitempty"`
Prefix string `json:"prefix,omitempty"`
}type ContactOrg struct {
Company string `json:"company,omitempty"`
Title string `json:"title,omitempty"`
Department string `json:"department,omitempty"`
}type ContactPhone struct {
Phone string `json:"phone,omitempty"`
WaId string `json:"wa_id,omitempty"`
Type PhoneType `json:"type" validate:"required"`
}type ContactUrl struct {
Url string `json:"url" validate:"required"`
Type UrlType `json:"type" validate:"required"`
}Context represents the context of the message.
type Context struct {
MessageId string `json:"message_id,omitempty"`
}DocumentMessage represents a document message.
type DocumentMessage struct {
Id string `json:"id,omitempty"`
Link *string `json:"link,omitempty"`
Caption *string `json:"caption,omitempty"`
FileName string `json:"filename" validate:"required"`
}func NewDocumentMessage(params DocumentMessageConfigs) (*DocumentMessage, error)NewDocumentMessage creates a new DocumentMessage instance.
func (dm *DocumentMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the DocumentMessage instance to JSON.
DocumentMessageApiPayload represents the API payload for a document message.
type DocumentMessageApiPayload struct {
BaseMessagePayload
Document DocumentMessage `json:"document" validate:"required"`
}DocumentMessageConfigs represents the configurations for a document message.
type DocumentMessageConfigs struct {
Id string `json:"id" validate:"required"`
Link *string `json:"link,omitempty"`
Caption *string `json:"caption,omitempty"`
FileName string `json:"filename" validate:"required"`
}type EmailType stringconst (
HomeEmail EmailType = "HOME"
WorkEmail EmailType = "WORK"
)ImageMessage represents a message with an image.
type ImageMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}func NewImageMessage(params ImageMessageConfigs) (*ImageMessage, error)NewImageMessage creates a new ImageMessage instance.
func (image *ImageMessage) SetCaption(params string)SetCaption sets the caption for the image message.
func (image *ImageMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the ImageMessage to JSON.
ImageMessageApiPayload represents the API payload for an image message.
type ImageMessageApiPayload struct {
BaseMessagePayload
Image ImageMessage `json:"image" validate:"required"`
}ImageMessageConfigs is an alias for ImageMessage.
type ImageMessageConfigs = ImageMessagetype InteractiveMessageType stringconst (
InteractiveMessageTypeButton InteractiveMessageType = "button"
InteractiveMessageTypeProduct InteractiveMessageType = "product"
InteractiveMessageTypeProductList InteractiveMessageType = "product_list"
InteractiveMessageTypeList InteractiveMessageType = "list"
InteractiveMessageTypeCatalog InteractiveMessageType = "catalog_message"
InteractiveMessageTypeLocationRequest InteractiveMessageType = "location_request_message"
)ListMessageApiPayload represents the API payload for the list message.
type ListMessageApiPayload struct {
BaseMessagePayload
Interactive listMessage `json:"interactive" validate:"required"` // Interactive message.
}ListMessageBody represents the body of the list message.
type ListMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the body.
}ListMessageFooter represents the footer of the list message.
type ListMessageFooter struct {
Text string `json:"text" validate:"required"` // Text of the footer.
}type ListMessageHeader struct {
Type string `json:"type" validate:"required"` // Type of the header.
Text string `json:"text" validate:"required"` // Text of the header.
}ListMessageParams represents the parameters for creating a list message.
type ListMessageParams struct {
ButtonText string `json:"-" validate:"required"` // Text of the button.
BodyText string `json:"-" validate:"required"` // Text of the body.
}ListSection represents a section in the list message.
type ListSection struct {
Title string `json:"title" validate:"required"` // Title of the section.
Rows []listSectionRow `json:"rows" validate:"required"` // Rows in the section.
}func NewListSection(title string) (*ListSection, error)NewListSection creates a new list section with the given title.
func (section *ListSection) AddRow(row *listSectionRow)AddRow adds a new row to the list section.
func (section *ListSection) SetTitle(title string)SetTitle sets the title of the list section.
LocationMessage represents a location message with latitude, longitude, address, and name.
type LocationMessage struct {
Latitude float64 `json:"latitude" validate:"required"` // Latitude of the location
Longitude float64 `json:"longitude" validate:"required"` // Longitude of the location
Address string `json:"address,omitempty"` // Address of the location (optional)
Name string `json:"name,omitempty"` // Name of the location (optional)
}func NewLocationMessage(latitude float64, longitude float64) (*LocationMessage, error)NewLocationMessage creates a new LocationMessage with the given latitude and longitude.
func (location *LocationMessage) SetAddress(params string)SetAddress sets the address of the location.
func (location *LocationMessage) SetName(params string)SetName sets the name of the location.
func (location *LocationMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the LocationMessage to JSON with the given configurations.
LocationMessageApiPayload represents the API payload for a location message.
type LocationMessageApiPayload struct {
BaseMessagePayload
Location LocationMessage `json:"location" validate:"required"` // Location message
}type LocationRequestMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the message.
Action locationMessageAction `json:"action" validate:"required"` // Action of the message.
Body LocationRequestMessageBody `json:"body,omitempty"` // Body of the message.
}func NewLocationRequestMessage(params LocationRequestMessageParams) (*LocationRequestMessage, error)func (m *LocationRequestMessage) SetBodyText(bodyText string)SetBodyText sets the body text of the list message.
func (m *LocationRequestMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the list message to JSON.
type LocationRequestMessageApiPayload struct {
BaseMessagePayload
Interactive LocationRequestMessage `json:"interactive" validate:"required"` // Interactive message.
}type LocationRequestMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the body.
}type LocationRequestMessageParams struct {
BodyText string `json:"-" validate:"required"` // Text of the body.
}MessageType represents the type of message.
type MessageType stringConstants for different message types.
const (
MessageTypeLocation MessageType = "location"
MessageTypeAudio MessageType = "audio"
MessageTypeVideo MessageType = "video"
MessageTypeDocument MessageType = "document"
MessageTypeText MessageType = "text"
MessageTypeContact MessageType = "contacts"
MessageTypeInteractive MessageType = "interactive"
MessageTypeTemplate MessageType = "template"
MessageTypeReaction MessageType = "reaction"
MessageTypeSticker MessageType = "sticker"
MessageTypeImage MessageType = "image"
)Order represents an order in the system.
type Order struct {
CatalogID string `json:"catalog_id"` // CatalogID is the ID of the catalog associated with the order.
ProductItems []ProductItem `json:"product_items"` // ProductItems is a list of product items in the order.
Text *string `json:"text"` // Text is an additional text associated with the order.
}type PhoneType stringconst (
CellPhone PhoneType = "CELL"
MainPhone PhoneType = "MAIN"
IphonePhone PhoneType = "IPHONE"
HomePhone PhoneType = "HOME"
WorkPhone PhoneType = "WORK"
)type Product struct {
RetailerId string `json:"product_retailer_id" validate:"required"`
}func (p *Product) SetRetailerId(id string)ProductItem represents a product item in an order.
type ProductItem struct {
Currency string `json:"currency"` // Currency is the currency of the product item.
ItemPrice float64 `json:"item_price"` // ItemPrice is the price of the product item.
ProductRetailerID string `json:"product_retailer_id"` // ProductRetailerID is the ID of the retailer associated with the product item.
Quantity int `json:"quantity"` // Quantity is the quantity of the product item.
}ProductListMessage represents a product list message.
type ProductListMessage struct {
Action ProductListMessageAction `json:"action" validate:"required"`
Body ProductListMessageBody `json:"body" validate:"required"`
Footer *ProductListMessageFooter `json:"footer,omitempty"`
Header ProductListMessageHeader `json:"header,omitempty"`
Type InteractiveMessageType `json:"type" validate:"required"`
}func NewProductListMessage(params ProductListMessageParams) (*ProductListMessage, error)NewProductListMessage creates a new product list message.
func (message *ProductListMessage) AddSection(section ProductSection)func (message *ProductListMessage) SetBody(text string)func (message *ProductListMessage) SetCatalogId(catalogId string)func (message *ProductListMessage) SetFooter(text string)func (message *ProductListMessage) SetHeader(text string)func (message *ProductListMessage) SetProductRetailerId(productRetailerId string)func (m *ProductListMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the product list message to JSON.
type ProductListMessageAction struct {
Sections []ProductSection `json:"sections" validate:"required"` // minimum 1 and maximum 10
CatalogId string `json:"catalog_id" validate:"required"`
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}func (a *ProductListMessageAction) AddSection(section ProductSection)ProductListMessageApiPayload represents the API payload for a product list message.
type ProductListMessageApiPayload struct {
BaseMessagePayload
Interactive ProductListMessage `json:"interactive" validate:"required"`
}type ProductListMessageBody struct {
Text string `json:"text" validate:"required"`
}type ProductListMessageFooter struct {
Text string `json:"text" validate:"required"`
}! TODO: support more header types
type ProductListMessageHeader struct {
Type ProductListMessageHeaderType `json:"type" validate:"required"`
Text string `json:"text" validate:"required"`
}type ProductListMessageHeaderType stringconst (
ProductListMessageHeaderTypeText ProductListMessageHeaderType = "text"
)ProductListMessageParams represents the parameters for creating a product list message.
type ProductListMessageParams struct {
CatalogId string `validate:"required"`
ProductRetailerId string `validate:"required"`
BodyText string `validate:"required"`
Sections []ProductSection
}ProductMessage represents a product message.
type ProductMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"`
Body *ProductMessageBody `json:"body" validate:"required"`
Footer *ProductMessageFooter `json:"footer,omitempty"`
Header *ProductMessageHeader `json:"header,omitempty"`
Action productMessageAction `json:"action" validate:"required"`
}func NewProductMessage(params ProductMessageParams) (*ProductMessage, error)NewProductMessage creates a new product message with the given parameters.
func (m *ProductMessage) SetBody(text string)func (m *ProductMessage) SetCatalogId(id string)func (m *ProductMessage) SetFooter(text string)func (m *ProductMessage) SetHeader(text string)func (m *ProductMessage) SetProductRetailerId(id string)func (m *ProductMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the product message to JSON with the given configurations.
ProductMessageApiPayload represents the API payload for a product message.
type ProductMessageApiPayload struct {
BaseMessagePayload
Interactive ProductMessage `json:"interactive" validate:"required"`
}type ProductMessageBody struct {
Text string `json:"text" validate:"required"`
}type ProductMessageFooter struct {
Text string `json:"text" validate:"required"`
}type ProductMessageHeader struct {
Text string `json:"text" validate:"required"`
}ProductMessageParams represents the parameters for creating a product message.
type ProductMessageParams struct {
CatalogId string `validate:"required"`
ProductRetailerId string `validate:"required"`
BodyText string `validate:"required"`
}type ProductSection struct {
Title string `json:"title" validate:"required"`
Products []Product `json:"product_items" validate:"required"`
}func (ps *ProductSection) AddProduct(product Product)func (ps *ProductSection) SetTitle(title string)QuickReplyButtonMessage represents a quick reply button message.
type QuickReplyButtonMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the quick reply button message.
Body QuickReplyButtonMessageBody `json:"body" validate:"required"` // Body of the quick reply button message.
Action QuickReplyButtonMessageAction `json:"action" validate:"required"` // Action of the quick reply button message.
Footer *QuickReplyButtonMessageFooter `json:"footer,omitempty"` // Footer of the quick reply button message.
Header *QuickReplyButtonMessageHeader `json:"header,omitempty"` // Header of the quick reply button message.
}func NewQuickReplyButtonMessage(bodyText string) (*QuickReplyButtonMessage, error)NewQuickReplyButtonMessage creates a new quick reply button message with the given body text.
func (m *QuickReplyButtonMessage) AddButton(id, title string) errorfunc (m *QuickReplyButtonMessage) SetFooter(text string)func (m *QuickReplyButtonMessage) SetHeader(text string)func (m *QuickReplyButtonMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the quick reply button message to JSON.
QuickReplyButtonMessageAction represents the action of a quick reply button message.
type QuickReplyButtonMessageAction struct {
Buttons []quickReplyButtonMessageButton `json:"buttons" validate:"required"` // List of quick reply buttons.
}QuickReplyButtonMessageApiPayload represents the API payload for a quick reply button message.
type QuickReplyButtonMessageApiPayload struct {
BaseMessagePayload
Interactive QuickReplyButtonMessage `json:"interactive" validate:"required"` // Interactive part of the API payload.
}QuickReplyButtonMessageBody represents the body of a quick reply button message.
type QuickReplyButtonMessageBody struct {
Text string `json:"text" validate:"required"` // Text of the quick reply button message.
}QuickReplyButtonMessageFooter represents the footer of a quick reply button message.
type QuickReplyButtonMessageFooter struct {
Text string `json:"text" validate:"required"` // Text of the quick reply button message footer.
}type QuickReplyButtonMessageHeader struct {
Type string `json:"type" validate:"required"` // Type of the quick reply button message header.
Text string `json:"text" validate:"required"` // Text of the quick reply button message header.
}ReactionMessage represents a reaction to a message.
type ReactionMessage struct {
MessageId string `json:"message_id" validate:"required"` // The ID of the message to react to.
Emoji string `json:"emoji" validate:"required"` // The emoji representing the reaction.
}func NewReactionMessage(params ReactionMessageParams) (*ReactionMessage, error)NewReactionMessage creates a new ReactionMessage instance.
func (reaction *ReactionMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the ReactionMessage to JSON.
ReactionMessageApiPayload represents the API payload for a reaction message.
type ReactionMessageApiPayload struct {
BaseMessagePayload
Reaction ReactionMessage `json:"reaction" validate:"required"` // The reaction message.
}ReactionMessageParams is an alias for ReactionMessage.
type ReactionMessageParams = ReactionMessageStickerMessage represents a sticker message.
type StickerMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}func NewStickerMessage(params *StickerMessageConfigs) (*StickerMessage, error)NewStickerMessage creates a new sticker message based on the provided configurations.
func (sticker *StickerMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the sticker message to JSON based on the provided configurations.
StickerMessageApiPayload represents the API payload for a sticker message.
type StickerMessageApiPayload struct {
BaseMessagePayload
Sticker StickerMessage `json:"sticker" validate:"required"`
}StickerMessageConfigs represents the configurations for a sticker message.
type StickerMessageConfigs struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
}TemplateMessage represents a template message.
type TemplateMessage struct {
Name string `json:"name" validate:"required"` // Template name.
Language TemplateMessageLanguage `json:"language" validate:"required"` // Language configuration.
Components []TemplateMessageComponent `json:"components" validate:"required"` // Array of components.
}func NewTemplateMessage(params *TemplateMessageConfigs) (*TemplateMessage, error)NewTemplateMessage creates a new TemplateMessage instance.
func (tm *TemplateMessage) AddBody(params TemplateMessageComponentBodyType)AddBody adds (or overrides) a body component in the template message. Only one body component is allowed.
func (tm *TemplateMessage) AddButton(params TemplateMessageComponentButtonType) errorAddButton adds a button component to the template message. A maximum of 10 buttons is allowed.
func (tm *TemplateMessage) AddHeader(params TemplateMessageComponentHeaderType)AddHeader adds (or overrides) a header component in the template message. Only one header is allowed.
func (m *TemplateMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the template message into a JSON payload compatible with the API.
TemplateMessageApiPayload represents the API payload for sending a template message.
type TemplateMessageApiPayload struct {
BaseMessagePayload
Template TemplateMessage `json:"template" validate:"required"`
}TemplateMessageBodyAndHeaderParameter represents parameters for body and header components.
type TemplateMessageBodyAndHeaderParameter struct {
Type TemplateMessageParameterType `json:"type" validate:"required"` // e.g., "text", "currency", etc.
ParameterName *string `json:"parameter_name,omitempty"` // Optional: name of the parameter (for named parameters).
Currency *TemplateMessageParameterCurrency `json:"currency,omitempty"` // Currency details (if type is currency).
DateTime *TemplateMessageParameterDateTime `json:"date_time,omitempty"` // Date/time details (if type is date_time).
Document *TemplateMessageParameterMedia `json:"document,omitempty"` // Document details (if type is document).
Image *TemplateMessageParameterMedia `json:"image,omitempty"` // Image details (if type is image).
Text *string `json:"text,omitempty"` // Text content (if type is text).
Video *TemplateMessageParameterMedia `json:"video,omitempty"` // Video details (if type is video).
Location *TemplateMessageParameterLocation `json:"location,omitempty"` // Location details (if type is location).
Product *TemplateMessageParameterProduct `json:"product,omitempty"` // Product details (if type is product).
}func (t TemplateMessageBodyAndHeaderParameter) GetParameterType() stringGetParameterType returns the parameter type as a string.
TemplateMessageButtonComponentType represents the subtype of a button component.
type TemplateMessageButtonComponentType stringconst (
TemplateMessageButtonComponentTypeQuickReply TemplateMessageButtonComponentType = "quick_reply"
TemplateMessageButtonComponentTypeUrl TemplateMessageButtonComponentType = "url"
TemplateMessageButtonComponentTypeCatalog TemplateMessageButtonComponentType = "catalog"
TemplateMessageButtonComponentTypeCopyCode TemplateMessageButtonComponentType = "copy_code"
TemplateMessageButtonComponentTypeMultiProductMessage TemplateMessageButtonComponentType = "mpm"
)TemplateMessageButtonParameter represents a parameter for a button component.
type TemplateMessageButtonParameter struct {
Type TemplateMessageButtonParameterType `json:"type" validate:"required"` // e.g., "payload" or "text" or "action"
Payload *string `json:"payload,omitempty"` // Required for quick_reply buttons.
Text *string `json:"text,omitempty"` // Required for URL buttons.
Action *TemplateMessageButtonParameterAction `json:"action,omitempty"` // Required for catalog buttons.
CouponCode *string `json:"coupon_code,omitempty"` // Required for copy code button in coupon_code parameter.
}func (t TemplateMessageButtonParameter) GetParameterType() stringGetParameterType returns the button parameter type as a string.
type TemplateMessageButtonParameterAction struct {
ThumbnailProductRetailerId string `json:"thumbnail_product_retailer_id" validate:"required"`
Sections *[]TemplateMessageMultiProductButtonActionParameterSection `json:"sections,omitempty"` // Required for MPM buttons. UPTO 10 sections in a buttons parameter
}TemplateMessageButtonParameterType represents the type for button parameters.
type TemplateMessageButtonParameterType stringconst (
TemplateMessageButtonParameterTypePayload TemplateMessageButtonParameterType = "payload"
TemplateMessageButtonParameterTypeText TemplateMessageButtonParameterType = "text"
TemplateMessageButtonParameterTypeAction TemplateMessageButtonParameterType = "action"
TemplateMessageButtonParameterTypeCouponCode TemplateMessageButtonParameterType = "coupon_code"
)type TemplateMessageCaraouselCard struct {
CardIndex int `json:"card_index" validate:"required"`
Components []TemplateMessageComponent `json:"components" validate:"required"` // only header, buttons and body
}TemplateMessageComponent is an interface for all template message components.
type TemplateMessageComponent interface {
GetComponentType() string
}TemplateMessageComponentBodyType represents a body component.
type TemplateMessageComponentBodyType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "body"
Parameters []TemplateMessageParameter `json:"parameters" validate:"required"` // Parameters for the body component.
}func (t TemplateMessageComponentBodyType) GetComponentType() stringGetComponentType returns the component type.
TemplateMessageComponentButtonType represents a button component.
type TemplateMessageComponentButtonType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // e.g., "button"
SubType TemplateMessageButtonComponentType `json:"sub_type" validate:"required"` // e.g., "quick_reply", "url", etc.
Index int `json:"index" validate:"required"` // Position index of the button (0 to 9)
Parameters *[]TemplateMessageParameter `json:"parameters,omitempty" validate:"required"` // Parameters for the button component.
}func (t TemplateMessageComponentButtonType) GetComponentType() stringtype TemplateMessageComponentCarouselType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "carousel"
Cards []TemplateMessageCaraouselCard `json:"cards" validate:"required"`
}TemplateMessageComponentHeaderType represents a header component.
type TemplateMessageComponentHeaderType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"` // "header"
Parameters *[]TemplateMessageParameter `json:"parameters,omitempty" validate:"required"` // Parameters for the header component.
}func (t TemplateMessageComponentHeaderType) GetComponentType() stringGetComponentType returns the component type.
type TemplateMessageComponentLimitedTimeOfferType struct {
Type TemplateMessageComponentType `json:"type" validate:"required"`
Parameters *[]TemplateMessageLimitedTimeOfferParameter `json:"parameters,omitempty" validate:"required"`
}func (t TemplateMessageComponentLimitedTimeOfferType) GetComponentType() stringTemplateMessageComponentType represents the type of a template message component.
type TemplateMessageComponentType stringconst (
TemplateMessageComponentTypeHeader TemplateMessageComponentType = "header"
TemplateMessageComponentTypeBody TemplateMessageComponentType = "body"
TemplateMessageComponentTypeButton TemplateMessageComponentType = "button"
TemplateMessageComponentTypeLimitedTimeOffer TemplateMessageComponentType = "limited_time_offer"
TemplateMessageComponentTypeCarousel TemplateMessageComponentType = "carousel"
)TemplateMessageConfigs represents basic configurations for a template message.
type TemplateMessageConfigs struct {
Name string `json:"name" validate:"required"` // Template name.
Language string `json:"language" validate:"required"` // Language code.
}TemplateMessageLanguage represents the language configuration.
type TemplateMessageLanguage struct {
Code string `json:"code" validate:"required"` // e.g., "en_US"
Policy string `json:"policy" validate:"required"` // e.g., "deterministic"
}type TemplateMessageLimitedTimeOfferParameter struct {
Type TemplateMessageParameterType `json:"type" validate:"required"` // e.g., "text", "currency", etc.
LimitedTimeOffer struct {
ExpirationTimeMs int64 `json:"expiration_time_ms" validate:"required"` // Expiration time in milliseconds.
} `json:"limited_time_offer" validate:"required"`
}type TemplateMessageMultiProductButtonActionParameterProductItem struct {
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}type TemplateMessageMultiProductButtonActionParameterSection struct {
Title string `json:"title" validate:"required"`
// Upto 30 product items only
ProductItems []TemplateMessageMultiProductButtonActionParameterProductItem `json:"product_items" validate:"required"`
}TemplateMessageParameter is an interface for all parameter types.
type TemplateMessageParameter interface {
GetParameterType() string
}TemplateMessageParameterCurrency represents a currency parameter.
type TemplateMessageParameterCurrency struct {
FallbackValue string `json:"fallback_value" validate:"required"` // Default text if localization fails.
Code string `json:"code" validate:"required"` // ISO 4217 currency code.
Amount1000 int `json:"amount_1000" validate:"required"` // Amount multiplied by 1000.
}TemplateMessageParameterDateTime represents a date-time parameter.
type TemplateMessageParameterDateTime struct {
FallbackValue string `json:"fallback_value" validate:"required"` // Default text if localization fails.
}TemplateMessageParameterLocation represents a location parameter.
type TemplateMessageParameterLocation struct {
Latitude string `json:"latitude" validate:"required"` // Latitude.
Longitude string `json:"longitude" validate:"required"` // Longitude.
Name string `json:"name" validate:"required"` // Location name.
Address string `json:"address" validate:"required"` // Address.
}TemplateMessageParameterMedia represents a media parameter (for document, image, video).
type TemplateMessageParameterMedia struct {
Link string `json:"link" validate:"required"` // URL link of the media.
}type TemplateMessageParameterProduct struct {
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
CatalogId string `json:"catalog_id" validate:"required"`
}TemplateMessageParameterType represents the type of a parameter.
type TemplateMessageParameterType stringconst (
TemplateMessageParameterTypeCurrency TemplateMessageParameterType = "currency"
TemplateMessageParameterTypeDateTime TemplateMessageParameterType = "date_time"
TemplateMessageParameterTypeDocument TemplateMessageParameterType = "document"
TemplateMessageParameterTypeImage TemplateMessageParameterType = "image"
TemplateMessageParameterTypeText TemplateMessageParameterType = "text"
TemplateMessageParameterTypeVideo TemplateMessageParameterType = "video"
TemplateMessageParameterTypeLocation TemplateMessageParameterType = "location"
TemplateMessageParameterTypeLimitedTimeOffer TemplateMessageParameterType = "limited_time_offer"
TemplateMessageParameterTypeProduct TemplateMessageParameterType = "product"
)TextMessageApiPayload represents the payload for the WhatsApp API.
type TextMessageApiPayload struct {
BaseMessagePayload `json:",inline"`
Text TextMessageApiPayloadText `json:"text" validate:"required"` // The text content of the message.
}TextMessageApiPayloadText represents the text payload for the WhatsApp API.
type TextMessageApiPayloadText struct {
Body string `json:"body" validate:"required"` // The text content of the message.
AllowPreview bool `json:"preview_url,omitempty"` // Whether to allow preview of the message.
}TextMessageConfigs represents the configuration options for a text message.
type TextMessageConfigs struct {
Text string `json:"text" validate:"required"` // The text content of the message.
AllowPreview bool `json:"allowPreview,omitempty"` // Whether to allow preview of the message.
}type UrlType stringVideoMessage represents a video message.
type VideoMessage struct {
Id string `json:"id,omitempty"`
Link string `json:"link,omitempty"`
Caption string `json:"caption,omitempty"`
}func NewVideoMessage(params VideoMessageConfigs) (*VideoMessage, error)NewVideoMessage creates a new VideoMessage instance.
func (video *VideoMessage) SetCaption(params string)SetCaption sets the caption for the video message.
func (video *VideoMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the video message to JSON.
VideoMessageApiPayload represents the API payload for a video message.
type VideoMessageApiPayload struct {
BaseMessagePayload
Video VideoMessage `json:"video" validate:"required"`
}VideoMessageConfigs is an alias for VideoMessage.
type VideoMessageConfigs = VideoMessagelistMessage represents an interactive list message.
type listMessage struct {
Type InteractiveMessageType `json:"type" validate:"required"` // Type of the message.
Action listMessageAction `json:"action" validate:"required"` // Action of the message.
Body ListMessageBody `json:"body,omitempty"` // Body of the message.
Footer *ListMessageFooter `json:"footer,omitempty"` // Footer of the message.
Header *ListMessageHeader `json:"header,omitempty"` // Header of the message.
}func NewListMessage(params ListMessageParams) (*listMessage, error)NewListMessage creates a new list message with the given parameters.
func (m *listMessage) AddSection(section *ListSection)AddSection adds a new section to the list message.
func (m *listMessage) SetBodyText(section *ListSection)SetBodyText sets the body text of the list message.
func (m *listMessage) SetFooterText(footerText string)func (m *listMessage) SetHeaderText(headerText string)func (m *listMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the list message to JSON.
listMessageAction represents the action of the list message.
type listMessageAction struct {
ButtonText string `json:"button" validate:"required"` // Text of the button.
Sections []ListSection `json:"sections" validate:"required"` // Sections in the list message.
}listSectionRow represents a row in the list section.
type listSectionRow struct {
Id string `json:"id" validate:"required"` // ID of the row.
Description string `json:"description" validate:"required"` // Description of the row.
Title string `json:"title" validate:"required"` // Title of the row.
}func NewListSectionRow(id, title, description string) (*listSectionRow, error)NewListSectionRow creates a new list section row with the given ID, title, and description.
func (row *listSectionRow) SetDescription(description string)SetDescription sets the description of the list section row.
func (row *listSectionRow) SetId(id string)SetId sets the ID of the list section row.
func (row *listSectionRow) SetTitle(title string)SetTitle sets the title of the list section row.
type locationMessageAction struct {
Name string `json:"name" validate:"required"` // Name of the action.
}type productMessageAction struct {
CatalogId string `json:"catalog_id" validate:"required"`
ProductRetailerId string `json:"product_retailer_id" validate:"required"`
}quickReplyButtonMessageButton represents a quick reply button.
type quickReplyButtonMessageButton struct {
Type string `json:"type" validate:"required"` // Type of the quick reply button.
Reply quickReplyButtonMessageButtonReply `json:"reply" validate:"required"` // Reply structure of the quick reply button.
}func NewQuickReplyButton(id, title string) (*quickReplyButtonMessageButton, error)NewQuickReplyButton creates a new quick reply button with the given ID and title.
quickReplyButtonMessageButtonReply represents the reply structure of a quick reply button.
type quickReplyButtonMessageButtonReply struct {
Title string `json:"title" validate:"required"` // Title of the quick reply button.
Id string `json:"id" validate:"required"` // ID of the quick reply button.
}textMessage represents a text message.
type textMessage struct {
Text string // The text content of the message.
AllowPreview bool // Whether to allow preview of the message.
}func NewTextMessage(configs TextMessageConfigs) (*textMessage, error)NewTextMessage creates a new text message with the given configurations.
func (m *textMessage) SetText(text string)SetText sets the text content of the message.
func (m *textMessage) ToJson(configs ApiCompatibleJsonConverterConfigs) ([]byte, error)ToJson converts the text message struct to WhatsApp API compatible JSON.