whatsapp_delete_message
Remove a sent message from a WhatsApp chat for all participants using message, chat, and sender IDs to correct errors or retract information.
Instructions
Delete a message for all participants in the chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | ID of the message to delete | |
| chatId | Yes | Chat ID where the message is located | |
| senderId | Yes | ID of the message sender |
Implementation Reference
- src/tools/messaging.ts:402-443 (handler)The core handler implementation for the 'whatsapp_delete_message' tool. It validates the input using deleteMessageSchema, logs the action, makes a PUT request to the WSAPI to delete the message, logs success, and returns a success response.export const deleteMessage: ToolHandler = { name: 'whatsapp_delete_message', description: 'Delete a message for all participants in the chat.', inputSchema: { type: 'object', properties: { messageId: { type: 'string', description: 'ID of the message to delete', }, chatId: { type: 'string', description: 'Chat ID where the message is located', }, senderId: { type: 'string', description: 'ID of the message sender', }, }, required: ['messageId', 'chatId', 'senderId'], }, handler: async (args: any) => { const input = validateInput(deleteMessageSchema, args); logger.info('Deleting message', { messageId: input.messageId, chatId: input.chatId, }); await wsapiClient.put(`/messages/${input.messageId}/delete`, { chatId: input.chatId, senderId: input.senderId, }); logger.info('Message deleted successfully', { messageId: input.messageId }); return { success: true, message: 'Message deleted successfully', }; }, };
- src/validation/schemas.ts:145-149 (schema)Zod schema for runtime validation of inputs to the whatsapp_delete_message handler. Defines structure for messageId, chatId, and senderId.export const deleteMessageSchema = z.object({ messageId: messageIdSchema, chatId: chatIdSchema, senderId: phoneNumberSchema, });
- src/tools/messaging.ts:544-555 (registration)The deleteMessage tool is included in the messagingTools object, which aggregates all messaging-related tools.export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
- src/server.ts:57-76 (registration)Registration of all tools including messagingTools (which contains whatsapp_delete_message) into the MCP server's tools Map in setupToolHandlers method.const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); });