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

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

Implementation Reference

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

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