send_contact_message
Send contact cards to WhatsApp numbers using the WhatsApp Business API. Share contact information including names, phone numbers, and emails through automated messaging.
Instructions
Send a contact card to a WhatsApp number.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient phone number | |
| contacts | Yes | Array of contact cards to send |
Implementation Reference
- src/whatsapp-client.ts:191-198 (handler)The implementation of the logic to send a contact message via the WhatsApp API.
async sendContactMessage(to: string, contacts: unknown[]) { return this.request(`/${this.config.phoneNumberId}/messages`, "POST", { messaging_product: "whatsapp", to, type: "contacts", contacts, }); } - src/index.ts:252-263 (schema)The input schema for the send_contact_message tool.
{ to: z.string().describe("Recipient phone number"), contacts: z .array( z.object({ name: z.object({ formatted_name: z.string(), first_name: z.string().optional() }), phones: z.array(z.object({ phone: z.string(), type: z.string().optional() })).optional(), emails: z.array(z.object({ email: z.string(), type: z.string().optional() })).optional(), }) ) .describe("Array of contact cards to send"), }, - src/index.ts:249-268 (registration)The registration of the send_contact_message MCP tool.
server.tool( "send_contact_message", "Send a contact card to a WhatsApp number.", { to: z.string().describe("Recipient phone number"), contacts: z .array( z.object({ name: z.object({ formatted_name: z.string(), first_name: z.string().optional() }), phones: z.array(z.object({ phone: z.string(), type: z.string().optional() })).optional(), emails: z.array(z.object({ email: z.string(), type: z.string().optional() })).optional(), }) ) .describe("Array of contact cards to send"), }, async ({ to, contacts }) => executeWithHooks("send_contact_message", { to, contacts }, config, () => wa.sendContactMessage(to, contacts) ) );