send_text_message
Send text messages to WhatsApp numbers within the 24-hour conversation window for customer communication and automated interactions.
Instructions
Send a text message to a WhatsApp number. Works within the 24-hour conversation window. For messages outside this window, use send_template_message instead.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient phone number in international format (e.g., 5541999999999) | |
| body | Yes | Message text content | |
| preview_url | No | Whether to show URL previews |
Implementation Reference
- src/whatsapp-client.ts:121-127 (handler)The core handler function in WhatsAppClient that executes the API request to send a text message.
async sendTextMessage(to: string, body: string, previewUrl = false) { return this.request(`/${this.config.phoneNumberId}/messages`, "POST", { messaging_product: "whatsapp", to, type: "text", text: { preview_url: previewUrl, body }, }); - src/index.ts:126-138 (registration)Registration of the send_text_message tool, including schema validation and the hook wrapper around the handler.
server.tool( "send_text_message", "Send a text message to a WhatsApp number. Works within the 24-hour conversation window. For messages outside this window, use send_template_message instead.", { to: z.string().describe("Recipient phone number in international format (e.g., 5541999999999)"), body: z.string().describe("Message text content"), preview_url: z.boolean().optional().default(false).describe("Whether to show URL previews"), }, async ({ to, body, preview_url }) => executeWithHooks("send_text_message", { to, body, preview_url }, config, () => wa.sendTextMessage(to, body, preview_url) ) );