Skip to main content
Glama

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
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)
messageIdYesMessage ID to edit
textYesNew message text
linkPreviewNoEnable link preview (default: true)
linkPreviewHighQualityNoEnable 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 handler
    name: "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"],
    },
  • 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}`,
          },
        ],
      };
    }
  • 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),
      });
    }
  • Dispatch case in MCP CallToolRequestSchema handler that routes to the specific tool handler.
    case "waha_edit_message":
      return await this.handleEditMessage(args);

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/seejux/waha-mcp'

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