waha_clear_chat_messages
Clear all messages from a WhatsApp chat. This destructive operation permanently removes chat history and cannot be undone.
Instructions
Clear all messages from a chat. WARNING: This is a destructive operation that cannot be undone.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) |
Implementation Reference
- src/index.ts:1466-1483 (handler)The primary handler function for the 'waha_clear_chat_messages' tool. It validates input, calls the WAHAClient.clearChatMessages method, and returns a confirmation message warning about the destructive nature of the operation.private async handleClearChatMessages(args: any) { const chatId = args.chatId; if (!chatId) { throw new Error("chatId is required"); } await this.wahaClient.clearChatMessages(chatId); return { content: [ { type: "text", text: `WARNING: All messages have been cleared from chat ${chatId}.\nThis operation cannot be undone.`, }, ], }; }
- src/index.ts:258-270 (schema)Input schema definition for the tool, specifying the required 'chatId' parameter and description.name: "waha_clear_chat_messages", description: "Clear all messages from a chat. WARNING: This is a destructive operation that cannot be undone.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, }, required: ["chatId"], }, },
- src/index.ts:1067-1073 (registration)Registration and dispatch logic in the CallToolRequestSchema handler's switch statement that routes calls to the specific handler function.case "waha_clear_chat_messages": return await this.handleClearChatMessages(args); case "waha_delete_chat": return await this.handleDeleteChat(args); case "waha_archive_chat": return await this.handleArchiveChat(args); case "waha_unarchive_chat":
- src/client/waha-client.ts:417-429 (helper)Underlying WAHAClient helper method that performs the actual HTTP DELETE request to the WAHA API endpoint to clear messages from the specified chat.async clearChatMessages(chatId: string): Promise<void> { if (!chatId) { throw new WAHAError("chatId is required"); } const endpoint = `/api/${this.session}/chats/${encodeURIComponent( chatId )}/messages`; await this.request<void>(endpoint, { method: "DELETE", }); }