Class: TextMessage
Represents a text message in WhatsApp.Implements
Extends
BaseMessage
<"text"
>
Implements
Constructors
new TextMessage()
new TextMessage(Creates a new instance of the TextMessage class.params
):TextMessage
Parameters
• params The parameters for creating the text message. • params.allowPreview?:true
Whether to allow preview of the message.
• params.text: string
The text content of the message.
Returns
TextMessage
Overrides
BaseMessage<"text">.constructor
Source
packages/wapi.js/src/structures/text/index.ts:31Properties
data
The data property of the text message.readonly
data:object
allowPreview?
optional
allowPreview:true
text
text: string
Implementation of
TextMessageInterface
.data
Source
packages/wapi.js/src/structures/text/index.ts:17messaging_product
messaging_product: "whatsapp"
The messaging product.
Implementation of
TextMessageInterface
.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
TextMessageInterface
.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
TextMessageInterface
.type
Inherited from
BaseMessage.type
Source
packages/wapi.js/src/structures/message/index.ts:16Methods
parseConstructorPayload()
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 text message to a WhatsApp Cloud API payload.params
):object
Parameters
• params The parameters for converting the message. • params.replyToMessageId?:string
The ID of the message to reply to.
• params.to: string
The recipient of the message.
Returns
object
The WhatsApp Cloud API payload for the text 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"
preview_url
preview_url: boolean
recipient_type
recipient_type: "individual"
text
text: object
text.body
body: string
text.preview_url?
optional
preview_url:boolean
to
to: string
type
type: Text
Implementation of
TextMessageInterface
.toJson
Overrides
BaseMessage.toJson