remove_group_member
Remove a participant from a WhatsApp group by providing the session ID, group ID, and the participant's phone ID.
Instructions
Remove a participant from a WhatsApp group
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| groupId | Yes | Group ID | |
| participantId | Yes | Phone ID of the participant to remove |
Implementation Reference
- src/tools/groups.ts:75-92 (registration)Registration of the 'remove_group_member' tool with its name, description, input schema, and handler logic. Calls openwaClient with DELETE method on the members endpoint.
server.registerTool( "remove_group_member", { description: "Remove a participant from a WhatsApp group", inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), participantId: z.string().describe("Phone ID of the participant to remove"), }, }, async ({ sessionId, groupId, participantId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/groups/${groupId}/members/${participantId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/groups.ts:76-84 (schema)Input schema defining sessionId (string), groupId (string), and participantId (string) as required parameters.
"remove_group_member", { description: "Remove a participant from a WhatsApp group", inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), participantId: z.string().describe("Phone ID of the participant to remove"), }, }, - src/tools/groups.ts:85-91 (handler)Handler function that executes the tool logic: sends a DELETE request to `/sessions/{sessionId}/groups/{groupId}/members/{participantId}` via openwaClient.
async ({ sessionId, groupId, participantId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/groups/${groupId}/members/${participantId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:18-18 (registration)Registration entry point: calls registerGroupTools(server) which registers remove_group_member.
registerGroupTools(server); - src/client.ts:10-35 (helper)The openwaClient helper function used by the 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; } }