TextMessage
Wapi.js Docs / TextMessage
Class: TextMessage
Represents a text message in WhatsApp.
Implements
Extends
BaseMessage
<"text"
>
Implements
Constructors
new TextMessage()
new TextMessage(
params
):TextMessage
Creates a new instance of the TextMessage class.
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
Overrides
BaseMessage<"text">.constructor
Source
packages/wapi.js/src/structures/text/index.ts:31
Properties
data
readonly
data:object
The data property of the text message.
allowPreview?
optional
allowPreview:true
text
text:
string
Implementation of
Source
packages/wapi.js/src/structures/text/index.ts:17
messaging_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:17
recipient_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:18
type
type:
MessageTypeEnum
The type of the message.
Implementation of
Inherited from
BaseMessage.type
Source
packages/wapi.js/src/structures/message/index.ts:16
Methods
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 text message to a WhatsApp Cloud API payload.
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
Overrides
BaseMessage.toJson
Memberof
TextMessage
Source
Was this page helpful?