waha_edit_message
Edit text in WhatsApp messages sent by the bot to correct errors or update information in existing conversations.
Instructions
Edit a sent message in a chat. Only works for messages sent by the bot.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) | |
| messageId | Yes | Message ID to edit | |
| text | Yes | New message text | |
| linkPreview | No | Enable link preview (default: true) | |
| linkPreviewHighQuality | No | Enable high quality link preview (default: false) |
Implementation Reference
- src/index.ts:185-214 (registration)MCP tool registration and input schema definition for 'waha_edit_message' in the listTools handlername: "waha_edit_message", description: "Edit a sent message in a chat. Only works for messages sent by the bot.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, messageId: { type: "string", description: "Message ID to edit", }, text: { type: "string", description: "New message text", }, linkPreview: { type: "boolean", description: "Enable link preview (default: true)", default: true, }, linkPreviewHighQuality: { type: "boolean", description: "Enable high quality link preview (default: false)", default: false, }, }, required: ["chatId", "messageId", "text"], },
- src/index.ts:1367-1402 (handler)Primary MCP tool handler for 'waha_edit_message'. Validates input, calls WAHAClient.editMessage, and formats success response.private async handleEditMessage(args: any) { const chatId = args.chatId; const messageId = args.messageId; const text = args.text; const linkPreview = args.linkPreview !== false; const linkPreviewHighQuality = args.linkPreviewHighQuality || false; if (!chatId) { throw new Error("chatId is required"); } if (!messageId) { throw new Error("messageId is required"); } if (!text) { throw new Error("text is required"); } await this.wahaClient.editMessage({ chatId, messageId, text, linkPreview, linkPreviewHighQuality, }); return { content: [ { type: "text", text: `Successfully edited message ${messageId} in chat ${chatId}.\nNew text: ${text}`, }, ], }; }
- src/client/waha-client.ts:320-355 (handler)Low-level WAHAClient.editMessage method that performs the actual PUT request to WAHA API to edit a message.async editMessage(params: { chatId: string; messageId: string; text: string; linkPreview?: boolean; linkPreviewHighQuality?: boolean; }): Promise<void> { const { chatId, messageId, text, linkPreview, linkPreviewHighQuality } = params; if (!chatId) { throw new WAHAError("chatId is required"); } if (!messageId) { throw new WAHAError("messageId is required"); } if (!text) { throw new WAHAError("text is required"); } const endpoint = `/api/${this.session}/chats/${encodeURIComponent( chatId )}/messages/${encodeURIComponent(messageId)}`; const body = { text, linkPreview: linkPreview !== false, linkPreviewHighQuality: linkPreviewHighQuality || false, }; await this.request<void>(endpoint, { method: "PUT", body: JSON.stringify(body), }); }
- src/index.ts:1061-1062 (handler)Dispatch case in MCP CallToolRequestSchema handler that routes to the specific tool handler.case "waha_edit_message": return await this.handleEditMessage(args);