Skip to main content
Glama

waha_send_message

Send text messages to WhatsApp chats through the WAHA MCP Server. Reply to existing messages and control link previews for effective communication.

Instructions

Send a text message to a WhatsApp chat. Returns message ID and delivery timestamp.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID to send message to (format: number@c.us)
textYesMessage text to send
replyToNoOptional: Message ID to reply to
linkPreviewNoEnable link preview (default: true)

Implementation Reference

  • The main handler function for the 'waha_send_message' tool. Validates input parameters (chatId, text), calls WAHAClient.sendTextMessage, formats the success response using formatSendMessageSuccess, and returns the result.
     * Handle waha_send_message tool
     */
    private async handleSendMessage(args: any) {
      const chatId = args.chatId;
      const text = args.text;
      const replyTo = args.replyTo;
      const linkPreview = args.linkPreview !== false; // Default true
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      if (!text) {
        throw new Error("text is required");
      }
    
      const response = await this.wahaClient.sendTextMessage({
        chatId,
        text,
        reply_to: replyTo,
        linkPreview,
      });
    
      const formattedResponse = formatSendMessageSuccess(
        chatId,
        response.id,
        response.timestamp
      );
    
      return {
        content: [
          {
            type: "text",
            text: formattedResponse,
          },
        ],
      };
    }
  • Input schema definition for the 'waha_send_message' tool, including properties, descriptions, defaults, and required fields. This is part of the tool list returned by ListToolsRequestHandler.
    {
      name: "waha_send_message",
      description: "Send a text message to a WhatsApp chat. Returns message ID and delivery timestamp.",
      inputSchema: {
        type: "object",
        properties: {
          chatId: {
            type: "string",
            description: "Chat ID to send message to (format: number@c.us)",
          },
          text: {
            type: "string",
            description: "Message text to send",
          },
          replyTo: {
            type: "string",
            description: "Optional: Message ID to reply to",
          },
          linkPreview: {
            type: "boolean",
            description: "Enable link preview (default: true)",
            default: true,
          },
        },
        required: ["chatId", "text"],
      },
    },
  • src/index.ts:1056-1057 (registration)
    Tool dispatch/registration in the CallToolRequestHandler switch statement, routing calls to 'waha_send_message' to the handleSendMessage function.
      return await this.handleSendMessage(args);
    case "waha_mark_chat_read":
  • Helper function to format the success response for send message operations, used in the tool handler.
    export function formatSendMessageSuccess(chatId: string, messageId: string, timestamp: number): string {
      return `Message sent successfully!\nChat: ${chatId}\nMessage ID: ${messageId}\nTime: ${formatTimestamp(timestamp)}`;
    }
  • Underlying WAHA API client method sendTextMessage that performs the actual HTTP POST to /api/sendText, called by the MCP tool handler.
    async sendTextMessage(
      params: SendTextMessageParams
    ): Promise<SendMessageResponse> {
      const { chatId, text, session, reply_to, linkPreview, linkPreviewHighQuality } = params;
    
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      if (!text) {
        throw new WAHAError("text is required");
      }
    
      const body = {
        chatId,
        text,
        session: session || this.session,
        reply_to,
        linkPreview: linkPreview !== false, // Default true
        linkPreviewHighQuality: linkPreviewHighQuality || false,
      };
    
      return this.request<SendMessageResponse>("/api/sendText", {
        method: "POST",
        body: JSON.stringify(body),
      });
    }

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