unblock_contact
Unblock a previously blocked WhatsApp contact by providing session ID and contact ID.
Instructions
Unblock a previously blocked WhatsApp contact
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| contactId | Yes | Contact ID to unblock |
Implementation Reference
- src/tools/contacts.ts:89-92 (handler)The handler function that executes the 'unblock_contact' tool logic. It sends a POST request to /sessions/{sessionId}/contacts/{contactId}/unblock via the openwaClient helper.
async ({ sessionId, contactId }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/contacts/${contactId}/unblock` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/contacts.ts:82-88 (schema)Input schema definition for the 'unblock_contact' tool. Requires sessionId (string) and contactId (string).
{ description: "Unblock a previously blocked WhatsApp contact", inputSchema: { sessionId: z.string().describe("Session ID"), contactId: z.string().describe("Contact ID to unblock"), }, }, - src/tools/contacts.ts:80-93 (registration)Registration of the 'unblock_contact' tool via server.registerTool() inside registerContactTools().
server.registerTool( "unblock_contact", { description: "Unblock a previously blocked WhatsApp contact", inputSchema: { sessionId: z.string().describe("Session ID"), contactId: z.string().describe("Contact ID to unblock"), }, }, async ({ sessionId, contactId }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/contacts/${contactId}/unblock` }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/index.ts:19-22 (registration)Where registerContactTools is called, which registers the tool on the MCP server.
registerContactTools(server); registerWebhookTools(server); registerLabelTools(server); registerMediaTools(server); - src/client.ts:10-35 (helper)The openwaClient helper function used by the handler to make HTTP requests to the OpenWA backend 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; } }