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)}`; }

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