Wapi.js Docs / TemplateMessage

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

TemplateMessage

Source

packages/wapi.js/src/structures/template/index.ts:115

Properties

data

data: object

language

language: LanguageEnum

templateName

templateName: string

Implementation of

TemplateMessageInterface.data

Source

packages/wapi.js/src/structures/template/index.ts:105

messaging_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:17

recipient_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:18

type

type: MessageTypeEnum
The type of the message.

Implementation of

TemplateMessageInterface.type

Inherited from

BaseMessage.type

Source

packages/wapi.js/src/structures/message/index.ts:16

Methods

addComponent()

addComponent(): void
Adds a component to the template message.

Returns

void

Source

packages/wapi.js/src/structures/template/index.ts:126

parseConstructorPayload()

protected parseConstructorPayload(schema, payload): any
Parses the constructor payload using the provided schema.

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:42

toJson()

toJson(params): object
Converts the template message to a JSON 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

Source

packages/wapi.js/src/structures/template/index.ts:135