whatsapp_delete_message
Delete WhatsApp messages for all chat participants using message ID, chat ID, and sender ID to remove unwanted content from group or individual conversations.
Instructions
Delete a message for all participants in the chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID where the message is located | |
| messageId | Yes | ID of the message to delete | |
| senderId | Yes | ID of the message sender |
Implementation Reference
- src/tools/messaging.ts:402-443 (handler)Full implementation of the whatsapp_delete_message tool handler, including inline inputSchema, validation using deleteMessageSchema, logging, API call to delete the message via wsapiClient, and 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 validation schema (deleteMessageSchema) used in the handler for input validation. Defines messageId, chatId, and senderId fields.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 export object.export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
- src/server.ts:53-79 (registration)Server's setupToolHandlers method imports and registers all tools from messagingTools (which includes whatsapp_delete_message) into the MCP server's tool map.private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories 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}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }