waha_send_message
Send text messages to WhatsApp chats through the WAHA MCP Server. Reply to existing messages and control link previews for effective communication.
Instructions
Send a text message to a WhatsApp chat. Returns message ID and delivery timestamp.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID to send message to (format: number@c.us) | |
| text | Yes | Message text to send | |
| replyTo | No | Optional: Message ID to reply to | |
| linkPreview | No | Enable link preview (default: true) |
Implementation Reference
- src/index.ts:1270-1307 (handler)The main handler function for the 'waha_send_message' tool. Validates input parameters (chatId, text), calls WAHAClient.sendTextMessage, formats the success response using formatSendMessageSuccess, and returns the result.* Handle waha_send_message tool */ private async handleSendMessage(args: any) { const chatId = args.chatId; const text = args.text; const replyTo = args.replyTo; const linkPreview = args.linkPreview !== false; // Default true if (!chatId) { throw new Error("chatId is required"); } if (!text) { throw new Error("text is required"); } const response = await this.wahaClient.sendTextMessage({ chatId, text, reply_to: replyTo, linkPreview, }); const formattedResponse = formatSendMessageSuccess( chatId, response.id, response.timestamp ); return { content: [ { type: "text", text: formattedResponse, }, ], }; }
- src/index.ts:115-141 (schema)Input schema definition for the 'waha_send_message' tool, including properties, descriptions, defaults, and required fields. This is part of the tool list returned by ListToolsRequestHandler.{ name: "waha_send_message", description: "Send a text message to a WhatsApp chat. Returns message ID and delivery timestamp.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID to send message to (format: number@c.us)", }, text: { type: "string", description: "Message text to send", }, replyTo: { type: "string", description: "Optional: Message ID to reply to", }, linkPreview: { type: "boolean", description: "Enable link preview (default: true)", default: true, }, }, required: ["chatId", "text"], }, },
- src/index.ts:1056-1057 (registration)Tool dispatch/registration in the CallToolRequestHandler switch statement, routing calls to 'waha_send_message' to the handleSendMessage function.return await this.handleSendMessage(args); case "waha_mark_chat_read":
- src/tools/formatters.ts:107-109 (helper)Helper function to format the success response for send message operations, used in the tool handler.export function formatSendMessageSuccess(chatId: string, messageId: string, timestamp: number): string { return `Message sent successfully!\nChat: ${chatId}\nMessage ID: ${messageId}\nTime: ${formatTimestamp(timestamp)}`; }
- src/client/waha-client.ts:193-219 (helper)Underlying WAHA API client method sendTextMessage that performs the actual HTTP POST to /api/sendText, called by the MCP tool handler.async sendTextMessage( params: SendTextMessageParams ): Promise<SendMessageResponse> { const { chatId, text, session, reply_to, linkPreview, linkPreviewHighQuality } = params; if (!chatId) { throw new WAHAError("chatId is required"); } if (!text) { throw new WAHAError("text is required"); } const body = { chatId, text, session: session || this.session, reply_to, linkPreview: linkPreview !== false, // Default true linkPreviewHighQuality: linkPreviewHighQuality || false, }; return this.request<SendMessageResponse>("/api/sendText", { method: "POST", body: JSON.stringify(body), }); }