Skip to main content
Glama
wsapi-chat
by wsapi-chat

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
NameRequiredDescriptionDefault
messageIdYesID of the message to delete
chatIdYesChat ID where the message is located
senderIdYesID of the message sender

Implementation Reference

  • 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', }; }, };
  • 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, });
  • 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}`); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wsapi-chat/wsapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server