Send Audio
send_audioTransmits an audio voice note to a WhatsApp recipient or group using a URL or base64 encoding.
Instructions
Send a WhatsApp audio (PTT voice note) via the pinned instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | Recipient JID or phone number (e.g. 5511999999999 or group@g.us) | |
| audio | Yes | URL or base64-encoded audio (ogg/opus preferred for WhatsApp) | |
| encoding | No | Set true if audio is base64 encoded | |
| delay | No | Delay in milliseconds before sending |
Implementation Reference
- src/tools/send-audio.ts:14-35 (handler)The handler for the 'send_audio' tool. Registers the tool with the MCP server, accepting args (number, audio, encoding, delay), posts to /message/sendWhatsAppAudio/{instanceName}, and returns the response as JSON.
export function registerSendAudio(server: McpServer, client: EvolutionClient): void { server.registerTool( "send_audio", { title: "Send Audio", description: "Send a WhatsApp audio (PTT voice note) via the pinned instance.", inputSchema: schema, }, async (args) => { try { const payload: Record<string, unknown> = { number: args.number, audio: args.audio }; if (args.encoding !== undefined) payload["encoding"] = args.encoding; if (args.delay !== undefined) payload["delay"] = args.delay; const data = await client.post(`/message/sendWhatsAppAudio/${client.instanceName}`, payload); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (e) { if (e instanceof McpError) return { isError: true, content: [{ type: "text" as const, text: e.message }] }; throw e; } } ); } - src/tools/send-audio.ts:7-12 (schema)Input schema defining 'number' (PhoneOrJidSchema), 'audio' (URL/base64 audio string), 'encoding' (optional boolean), and 'delay' (optional number in ms).
const schema = { number: PhoneOrJidSchema, audio: z.string().min(1).describe("URL or base64-encoded audio (ogg/opus preferred for WhatsApp)"), encoding: z.boolean().optional().describe("Set true if audio is base64 encoded"), delay: z.number().int().nonnegative().optional().describe("Delay in milliseconds before sending"), }; - src/tools/index.ts:89-89 (registration)Registration call: registerSendAudio(server, client) invoked inside registerAllTools.
registerSendAudio(server, client); - src/tools/index.ts:16-16 (registration)Import of registerSendAudio from ./send-audio.js in the main tools index.
import { registerSendAudio } from "./send-audio.js"; - src/schemas.ts:8-11 (helper)PhoneOrJidSchema helper used by the send-audio tool schema to validate the recipient field.
export const PhoneOrJidSchema = z .string() .min(1) .describe("Recipient JID or phone number (e.g. 5511999999999 or group@g.us)");