Skip to main content

Text Messages

Text messages are the foundation of WhatsApp communication. The SDK provides a simple yet powerful interface for sending text messages with advanced features like URL previews and reply support.

Basic Usage

Method Signature

Parameters

  • to (string): Recipient phone number in international format
  • text (string): Message content (max 4,096 characters)
  • options (TextOptions, optional): Additional message options

TextOptions Interface

Examples

Basic Text Message

Text with URL Preview

Reply to Message

Formatted Text with Emojis

Multi-line Messages

Character Limits and Validation

Maximum Length

Text messages are limited to 4,096 characters. The SDK automatically validates this:

Character Counting

URL Preview Feature

When previewUrl is enabled, WhatsApp will generate a preview for the first URL found in the message.

URL Preview Examples

URL Preview Best Practices

Reply Messages

Reply to specific messages to maintain conversation context:

Basic Reply

Contextual Replies

Text Formatting and Styling

Emoji Usage

Text Structure

Advanced Use Cases

Dynamic Content

Conditional Messaging

Template-like Messages

Error Handling

Common Errors

Retry Logic

Best Practices

1. Message Length

2. URL Preview Usage

3. Reply Context

Next Steps

Media Messages

Learn to send images, videos, and documents

Interactive Messages

Create buttons and lists for user interaction

Webhook Handling

Handle incoming text messages and replies

Template Messages

Use pre-approved templates for business messaging