send_bulk_image
Send an image to multiple WhatsApp contacts at once using a single request. Specify recipients, image URL, and optional caption.
Instructions
Send the same image 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 | |
| url | Yes | Public URL of the image | |
| caption | No | Optional caption for the image |
Implementation Reference
- src/tools/bulk.ts:26-45 (registration)Tool 'send_bulk_image' is registered via server.registerTool with schema definition and async handler.
server.registerTool( "send_bulk_image", { description: "Send the same image 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"), url: z.string().describe("Public URL of the image"), caption: z.string().optional().describe("Optional caption for the image"), }, }, async ({ sessionId, recipients, url, caption }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-bulk`, body: { recipients, url, caption }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/bulk.ts:30-35 (schema)Input schema for send_bulk_image: sessionId (string), recipients (string[]), url (string), caption (optional string).
inputSchema: { sessionId: z.string().describe("Session ID to send from"), recipients: z.array(z.string()).describe("Array of chat IDs to send to"), url: z.string().describe("Public URL of the image"), caption: z.string().optional().describe("Optional caption for the image"), }, - src/tools/bulk.ts:37-44 (handler)Handler performs a POST to /sessions/{sessionId}/messages/send-bulk with recipients, url, and caption.
async ({ sessionId, recipients, url, caption }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-bulk`, body: { recipients, url, caption }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/client.ts:10-35 (helper)openwaClient helper function handles HTTP calls with fetch, JSON serialization, error handling, and API key auth.
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; } } - src/index.ts:6-6 (registration)Registration entry point: registerBulkTools is imported from src/tools/bulk.ts and called at startup.
import { registerBulkTools } from "./tools/bulk.js";