send_video
Send a video to a WhatsApp chat by providing a publicly accessible URL. Optionally include a caption.
Instructions
Send a video to a WhatsApp chat by providing a publicly accessible URL
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID to send from | |
| chatId | Yes | Target chat ID | |
| url | Yes | Public URL of the video | |
| caption | No | Optional caption for the video |
Implementation Reference
- src/tools/messages.ts:89-108 (registration)Registration of the 'send_video' tool via server.registerTool(...)
server.registerTool( "send_video", { description: "Send a video to a WhatsApp chat by providing a publicly accessible URL", inputSchema: { sessionId: z.string().describe("Session ID to send from"), chatId: z.string().describe("Target chat ID"), url: z.string().describe("Public URL of the video"), caption: z.string().optional().describe("Optional caption for the video"), }, }, async ({ sessionId, chatId, url, caption }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-video`, body: { chatId, url, caption }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/messages.ts:100-108 (handler)Handler function for 'send_video' that calls openwaClient to POST to /sessions/{sessionId}/messages/send-video
async ({ sessionId, chatId, url, caption }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/messages/send-video`, body: { chatId, url, caption }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/messages.ts:92-98 (schema)Input schema for 'send_video' tool: sessionId, chatId, url, and optional caption
description: "Send a video to a WhatsApp chat by providing a publicly accessible URL", inputSchema: { sessionId: z.string().describe("Session ID to send from"), chatId: z.string().describe("Target chat ID"), url: z.string().describe("Public URL of the video"), caption: z.string().optional().describe("Optional caption for the video"), }, - src/index.ts:15-15 (registration)Registration of message tools (including send_video) via registerMessageTools(server)
registerSessionTools(server); - src/client.ts:10-35 (helper)openwaClient helper function used by the send_video handler to make HTTP requests to the OpenWA API
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; } }