> ## Documentation Index
> Fetch the complete documentation index at: https://javascript.wapikit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TextMessage

[Wapi.js Docs](../README.mdx) / TextMessage

# Class: TextMessage

Represents a text message in WhatsApp.

## Implements

## Extends

* `BaseMessage`\<`"text"`>

## Implements

* [`TextMessageInterface`](../interfaces/TextMessageInterface.mdx)

## Constructors

### new TextMessage()

> **new TextMessage**(`params`): [`TextMessage`](TextMessage.mdx)

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

[`TextMessage`](TextMessage.mdx)

#### Overrides

`BaseMessage<"text">.constructor`

#### Source

[packages/wapi.js/src/structures/text/index.ts:31](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/text/index.ts#L31)

## Properties

### data

> `readonly` **data**: `object`

The data property of the text message.

#### allowPreview?

> `optional` **allowPreview**: `true`

#### text

> **text**: `string`

#### Implementation of

[`TextMessageInterface`](../interfaces/TextMessageInterface.mdx).[`data`](../interfaces/TextMessageInterface.mdx#data)

#### Source

[packages/wapi.js/src/structures/text/index.ts:17](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/text/index.ts#L17)

***

### messaging\_product

> **messaging\_product**: `"whatsapp"`

The messaging product.

#### Implementation of

[`TextMessageInterface`](../interfaces/TextMessageInterface.mdx).[`messaging_product`](../interfaces/TextMessageInterface.mdx#messaging_product)

#### Inherited from

`BaseMessage.messaging_product`

#### Source

[packages/wapi.js/src/structures/message/index.ts:17](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/message/index.ts#L17)

***

### recipient\_type

> **recipient\_type**: `"individual"`

The recipient type.

#### Implementation of

[`TextMessageInterface`](../interfaces/TextMessageInterface.mdx).[`recipient_type`](../interfaces/TextMessageInterface.mdx#recipient_type)

#### Inherited from

`BaseMessage.recipient_type`

#### Source

[packages/wapi.js/src/structures/message/index.ts:18](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/message/index.ts#L18)

***

### type

> **type**: `MessageTypeEnum`

The type of the message.

#### Implementation of

[`TextMessageInterface`](../interfaces/TextMessageInterface.mdx).[`type`](../interfaces/TextMessageInterface.mdx#type)

#### Inherited from

`BaseMessage.type`

#### Source

[packages/wapi.js/src/structures/message/index.ts:16](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/message/index.ts#L16)

## 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](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/message/index.ts#L42)

***

### 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

[`TextMessageInterface`](../interfaces/TextMessageInterface.mdx).[`toJson`](../interfaces/TextMessageInterface.mdx#tojson)

#### Overrides

`BaseMessage.toJson`

#### Memberof

TextMessage

#### Source

[packages/wapi.js/src/structures/text/index.ts:48](https://github.com/sarthakjdev/wapi.js/blob/1b066ed4efaf997a4bb012da51514dfcb4165da6/packages/wapi.js/src/structures/text/index.ts#L48)
