Skip to main content
Glama
wsapi-chat
by wsapi-chat

whatsapp_send_voice

Send voice messages to WhatsApp contacts or groups using URL or base64 data. Supports mentions, replies, forwarding, and view-once options.

Instructions

Send a voice message (PTT) to a WhatsApp contact or group. Can send from URL or base64.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient phone number (with @s.whatsapp.net) or group ID (with @g.us)
voiceBase64NoBase64 encoded voice data (alternative to voiceURL)
voiceURLNoURL of the voice file to send (alternative to voiceBase64)
mentionsNoList of phone numbers to mention
replyToNoID of the message being replied to
isForwardedNoWhether the message should be marked as forwarded
viewOnceNoWhether the voice message should be sent as view-once

Implementation Reference

  • Complete ToolHandler definition for 'whatsapp_send_voice', including input schema, description, and the core handler logic that validates input using sendVoiceMessageSchema and sends the voice message via wsapiClient.post('/messages/voice', input).
    export const sendVoiceMessage: ToolHandler = { name: 'whatsapp_send_voice', description: 'Send a voice message (PTT) to a WhatsApp contact or group. Can send from URL or base64.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, voiceBase64: { type: 'string', description: 'Base64 encoded voice data (alternative to voiceURL)', optional: true, }, voiceURL: { type: 'string', description: 'URL of the voice file to send (alternative to voiceBase64)', optional: true, }, mentions: { type: 'array', items: { type: 'string' }, description: 'List of phone numbers to mention', optional: true, }, replyTo: { type: 'string', description: 'ID of the message being replied to', optional: true, }, isForwarded: { type: 'boolean', description: 'Whether the message should be marked as forwarded', optional: true, }, viewOnce: { type: 'boolean', description: 'Whether the voice message should be sent as view-once', optional: true, }, }, required: ['to'], }, handler: async (args: any) => { const input = validateInput(sendVoiceMessageSchema, args) as SendVoiceMessageInput; logger.info('Sending voice message', { to: input.to, viewOnce: input.viewOnce, }); const result = await wsapiClient.post('/messages/voice', input); logger.info('Voice message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Voice message sent successfully', }; }, };
  • Zod schema definition for SendVoiceMessageInput validation, used in the tool handler via validateInput.
    export const sendVoiceMessageSchema = z.object({ to: chatIdSchema, voiceBase64: base64Schema.optional(), voiceURL: urlSchema.optional(), mentions: z.array(phoneNumberSchema).optional(), replyTo: messageIdSchema.optional(), isForwarded: z.boolean().optional(), viewOnce: z.boolean().optional(), }).refine(data => data.voiceBase64 || data.voiceURL, { message: "Either voiceBase64 or voiceURL must be provided", });
  • src/server.ts:53-79 (registration)
    Registers all tools, including 'whatsapp_send_voice' from messagingTools, into the server's tools Map for MCP handling.
    private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
  • Collects and exports messagingTools by importing and spreading advancedMessagingTools, which includes sendVoiceMessage.
    import { advancedMessagingTools } from './messaging-advanced.js'; // Export all messaging tools export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };

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/wsapi-chat/wsapi-mcp'

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