Class: TemplateMessage
Represents a template message.Extends
BaseMessage
<MessageTypeEnum.Template
>
Implements
Constructors
new TemplateMessage()
new TemplateMessage(params
):TemplateMessage
Parameters
• params The template message data. • params.language:LanguageEnum
• params.templateName: string
Returns
TemplateMessage
Overrides
BaseMessage<MessageTypeEnum.Template>.constructor
Memberof
TemplateMessageSource
packages/wapi.js/src/structures/template/index.ts:115Properties
data
data: object
language
language: LanguageEnum
templateName
templateName: string
Implementation of
TemplateMessageInterface
.data
Source
packages/wapi.js/src/structures/template/index.ts:105messaging_product
messaging_product: "whatsapp"
The messaging product.
Implementation of
TemplateMessageInterface
.messaging_product
Inherited from
BaseMessage.messaging_product
Source
packages/wapi.js/src/structures/message/index.ts:17recipient_type
recipient_type: "individual"
The recipient type.
Implementation of
TemplateMessageInterface
.recipient_type
Inherited from
BaseMessage.recipient_type
Source
packages/wapi.js/src/structures/message/index.ts:18type
type: MessageTypeEnum
The type of the message.
Implementation of
TemplateMessageInterface
.type
Inherited from
BaseMessage.type
Source
packages/wapi.js/src/structures/message/index.ts:16Methods
addComponent()
addComponent(): void
Adds a component to the template message.
Returns
void
Source
packages/wapi.js/src/structures/template/index.ts:126parseConstructorPayload()
Parses the constructor payload using the provided schema.protected
parseConstructorPayload(schema
,payload
):any
Parameters
• schema:ZodType
<any
, ZodTypeDef
, any
>
The Zod schema used for parsing the payload.
• payload: any
The payload to be parsed.
Returns
any
The parsed data.
Inherited from
BaseMessage.parseConstructorPayload
Throws
An error if the parsing fails.Source
packages/wapi.js/src/structures/message/index.ts:42toJson()
toJson(Converts the template message to a JSON object.params
):object
Parameters
• params The parameters for the JSON object. • params.replyToMessageId?:string
• params.to: string
Returns
object
The JSON object representing the template message.
biz_opaque_callback_data?
optional
biz_opaque_callback_data:string
context?
optional
context:object
context.message_id
message_id: string
messaging_product
messaging_product: "whatsapp"
recipient_type
recipient_type: "individual"
template
template: object
template.components?
optional
components: (object
|object
|object
)[]
template.language
language: object
template.language.code
code: LanguageEnum
template.language.policy
policy: "deterministic"
template.name
name: string
to
to: string
type
type: Template
Overrides
BaseMessage.toJson