send_bulk_text
Send the same text message to multiple WhatsApp recipients at once by specifying the session, chat IDs, and message content.
Instructions
Send the same text message to multiple WhatsApp recipients at once
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID to send from | |
| recipients | Yes | Array of chat IDs to send to | |
| text | Yes | Message text content |
Implementation Reference
- src/tools/bulk.ts:16-23 (handler)Handler function that sends a bulk text message by calling the OpenWA API's send-bulk endpoint with recipients and text.
async ({ sessionId, recipients, text }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-bulk`, body: { recipients, text }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/bulk.ts:10-14 (schema)Zod schema defining the input parameters for send_bulk_text: sessionId (string), recipients (array of strings), and text (string).
inputSchema: { sessionId: z.string().describe("Session ID to send from"), recipients: z.array(z.string()).describe("Array of chat IDs to send to"), text: z.string().describe("Message text content"), }, - src/tools/bulk.ts:6-24 (registration)Registration of the send_bulk_text tool on the McpServer via server.registerTool with description, inputSchema, and handler callback.
server.registerTool( "send_bulk_text", { description: "Send the same text message to multiple WhatsApp recipients at once", inputSchema: { sessionId: z.string().describe("Session ID to send from"), recipients: z.array(z.string()).describe("Array of chat IDs to send to"), text: z.string().describe("Message text content"), }, }, async ({ sessionId, recipients, text }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-bulk`, body: { recipients, text }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/index.ts:17-17 (registration)Registration call in the main entry point that wires up the bulk tools (including send_bulk_text) onto the server.
registerBulkTools(server); - src/client.ts:10-35 (helper)Helper HTTP client that sends the actual POST request to the OpenWA API endpoint for bulk messaging.
export async function openwaClient<T = unknown>(opts: RequestOptions): Promise<T> { const url = `${BASE_URL}${opts.path}`; const headers: Record<string, string> = { "Content-Type": "application/json", "X-API-Key": API_KEY, }; const res = await fetch(url, { method: opts.method, headers, body: opts.body ? JSON.stringify(opts.body) : undefined, }); const text = await res.text(); if (!res.ok) { throw new Error(`OpenWA API ${res.status}: ${text}`); } try { return JSON.parse(text) as T; } catch { return text as T; } }