whatsapp_edit_message
Edit text in previously sent WhatsApp messages by providing the message ID, chat ID, and new content to correct errors or update information.
Instructions
Edit a previously sent text message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | ID of the message to edit | |
| text | Yes | New text content for the message (max 4096 characters) | |
| to | Yes | Chat ID where the message is located |
Implementation Reference
- src/tools/messaging.ts:356-399 (handler)Core implementation of the 'whatsapp_edit_message' tool handler. Validates input, logs activity, performs PUT request to WSAPI /messages/{id}/text endpoint to update message text, and returns success response with new message ID.export const editMessage: ToolHandler = { name: 'whatsapp_edit_message', description: 'Edit a previously sent text message.', inputSchema: { type: 'object', properties: { messageId: { type: 'string', description: 'ID of the message to edit', }, to: { type: 'string', description: 'Chat ID where the message is located', }, text: { type: 'string', description: 'New text content for the message (max 4096 characters)', }, }, required: ['messageId', 'to', 'text'], }, handler: async (args: any) => { const input = validateInput(editMessageSchema, args); logger.info('Editing message', { messageId: input.messageId, to: input.to, textLength: input.text.length, }); const result = await wsapiClient.put(`/messages/${input.messageId}/text`, { to: input.to, text: input.text, }); logger.info('Message edited successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Message edited successfully', }; }, };
- src/validation/schemas.ts:139-143 (schema)Zod validation schema for 'whatsapp_edit_message' tool input, defining messageId, to (chat ID), and new text with constraints.export const editMessageSchema = z.object({ messageId: messageIdSchema, to: chatIdSchema, text: z.string().min(1).max(4096), });
- src/tools/messaging.ts:544-555 (registration)Export of messagingTools object that bundles the editMessage tool (whatsapp_edit_message) for registration in the MCP server.export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
- src/server.ts:53-79 (registration)Server method that registers all tools from messagingTools (including whatsapp_edit_message) into the MCP server's tools Map by iterating over tool categories.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`); }