Skip to main content
Glama

waha_send_audio

Send audio or voice messages to WhatsApp chats using URL links or base64 encoded data. Specify chat ID and MIME type to deliver audio files directly through the WAHA MCP Server.

Instructions

Send audio/voice messages to a WhatsApp chat. Supports URL or base64 data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)
fileUrlNoURL of the audio file to send (use either fileUrl or fileData, not both)
fileDataNoBase64 encoded audio data (use either fileUrl or fileData, not both)
mimetypeYesMIME type of the audio file (e.g., 'audio/ogg', 'audio/mpeg')
filenameNoOptional filename for the audio
replyToNoOptional message ID to reply to

Implementation Reference

  • Main execution handler for waha_send_audio tool. Validates parameters, prepares file object from URL or base64 data, calls WAHA client sendAudio method, and returns formatted success response with message ID and timestamp.
    private async handleSendAudio(args: any) {
      const chatId = args.chatId;
      const fileUrl = args.fileUrl;
      const fileData = args.fileData;
      const mimetype = args.mimetype;
      const filename = args.filename;
      const replyTo = args.replyTo;
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      if (!mimetype) {
        throw new Error("mimetype is required");
      }
    
      if (!fileUrl && !fileData) {
        throw new Error("Either fileUrl or fileData is required");
      }
    
      const file: any = {
        mimetype,
        filename,
      };
    
      if (fileUrl) {
        file.url = fileUrl;
      } else {
        file.data = fileData;
      }
    
      const response = await this.wahaClient.sendAudio({
        chatId,
        file,
        reply_to: replyTo,
      });
    
      const formattedResponse = formatSendMessageSuccess(
        chatId,
        response.id,
        response.timestamp
      );
    
      return {
        content: [
          {
            type: "text",
            text: `${formattedResponse}\nMedia type: audio/voice`,
          },
        ],
      };
    }
  • src/index.ts:389-422 (registration)
    Tool registration in ListTools handler, including name, description, and complete input schema definition for parameter validation.
    {
      name: "waha_send_audio",
      description: "Send audio/voice messages to a WhatsApp chat. Supports URL or base64 data.",
      inputSchema: {
        type: "object",
        properties: {
          chatId: {
            type: "string",
            description: "Chat ID (format: number@c.us)",
          },
          fileUrl: {
            type: "string",
            description: "URL of the audio file to send (use either fileUrl or fileData, not both)",
          },
          fileData: {
            type: "string",
            description: "Base64 encoded audio data (use either fileUrl or fileData, not both)",
          },
          mimetype: {
            type: "string",
            description: "MIME type of the audio file (e.g., 'audio/ogg', 'audio/mpeg')",
          },
          filename: {
            type: "string",
            description: "Optional filename for the audio",
          },
          replyTo: {
            type: "string",
            description: "Optional message ID to reply to",
          },
        },
        required: ["chatId", "mimetype"],
      },
    },
  • Input schema for waha_send_audio tool defining structure, types, descriptions, and required fields for validation.
    inputSchema: {
      type: "object",
      properties: {
        chatId: {
          type: "string",
          description: "Chat ID (format: number@c.us)",
        },
        fileUrl: {
          type: "string",
          description: "URL of the audio file to send (use either fileUrl or fileData, not both)",
        },
        fileData: {
          type: "string",
          description: "Base64 encoded audio data (use either fileUrl or fileData, not both)",
        },
        mimetype: {
          type: "string",
          description: "MIME type of the audio file (e.g., 'audio/ogg', 'audio/mpeg')",
        },
        filename: {
          type: "string",
          description: "Optional filename for the audio",
        },
        replyTo: {
          type: "string",
          description: "Optional message ID to reply to",
        },
      },
      required: ["chatId", "mimetype"],
    },
  • Core WAHA client helper method that performs the actual HTTP POST to /api/sendVoice endpoint to send audio message.
    async sendAudio(params: {
      chatId: string;
      file: {
        mimetype: string;
        url?: string;
        data?: string; // base64
        filename?: string;
      };
      reply_to?: string;
    }): Promise<SendMessageResponse> {
      const { chatId, file, reply_to } = params;
    
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      if (!file || (!file.url && !file.data)) {
        throw new WAHAError("file with url or data is required");
      }
    
      const body = {
        chatId,
        file,
        session: this.session,
        reply_to,
      };
    
      return this.request<SendMessageResponse>("/api/sendVoice", {
        method: "POST",
        body: JSON.stringify(body),
      });
    }
  • Utility function used by the handler to format the success response text.
    export function formatSendMessageSuccess(chatId: string, messageId: string, timestamp: number): string {
      return `Message sent successfully!\nChat: ${chatId}\nMessage ID: ${messageId}\nTime: ${formatTimestamp(timestamp)}`;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but provides minimal behavioral information. It mentions the two input methods (URL or base64) but doesn't disclose important behaviors like: whether this is a synchronous or asynchronous operation, what happens if the audio file is too large, whether there are rate limits, what permissions are required, or what the typical response looks like. 'Send' implies a write operation, but no safety warnings or side effects are described.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences with zero waste. The first sentence states the core purpose, the second adds technical detail about input methods. However, it could be more front-loaded by mentioning the exclusive choice between fileUrl and fileData upfront.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 6-parameter tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens after sending (success/failure indicators), doesn't mention authentication requirements, doesn't warn about potential side effects (like message delivery notifications), and provides no context about WhatsApp-specific constraints. The description leaves too many behavioral questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema - it mentions URL or base64 options (implied by fileUrl/fileData parameters) and specifies 'audio/voice messages' (implied by mimetype). No additional semantic context about parameter relationships or usage patterns is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send audio/voice messages') and target ('to a WhatsApp chat'), with specific media type mentioned. It distinguishes from generic 'send_media' by focusing on audio, but doesn't explicitly differentiate from other messaging tools like 'send_message'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'send_media' or 'send_message'. The description mentions support for URL or base64 data, but this is technical implementation detail rather than usage context. No mention of prerequisites, error conditions, or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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