waha_send_contact
Send contact cards to WhatsApp chats using vCard format. Share contact information by specifying chat ID and vCard data, with optional message reply functionality.
Instructions
Send contact card(s) to a WhatsApp chat using vCard format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) | |
| vcard | Yes | vCard formatted contact data (e.g., 'BEGIN:VCARD\nVERSION:3.0\nFN:Jane Doe\nTEL:+1234567890\nEND:VCARD') | |
| replyTo | No | Optional message ID to reply to |
Implementation Reference
- src/index.ts:1764-1797 (handler)The main handler function that executes the waha_send_contact tool logic, validating inputs, calling WAHAClient.sendContact, formatting response with formatSendMessageSuccessprivate async handleSendContact(args: any) { const chatId = args.chatId; const vcard = args.vcard; const replyTo = args.replyTo; if (!chatId) { throw new Error("chatId is required"); } if (!vcard) { throw new Error("vcard is required"); } const response = await this.wahaClient.sendContact({ chatId, contacts: [{ vcard }], reply_to: replyTo, }); const formattedResponse = formatSendMessageSuccess( chatId, response.id, response.timestamp ); return { content: [ { type: "text", text: `${formattedResponse}\nContact card sent successfully.`, }, ], }; }
- src/index.ts:454-474 (schema)Input schema definition and description for the waha_send_contact tool, registered in ListToolsRequestSchema handlername: "waha_send_contact", description: "Send contact card(s) to a WhatsApp chat using vCard format.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, vcard: { type: "string", description: "vCard formatted contact data (e.g., 'BEGIN:VCARD\\nVERSION:3.0\\nFN:Jane Doe\\nTEL:+1234567890\\nEND:VCARD')", }, replyTo: { type: "string", description: "Optional message ID to reply to", }, }, required: ["chatId", "vcard"], }, },
- src/index.ts:1085-1086 (registration)Tool dispatch/registration in the CallToolRequestSchema switch statementcase "waha_send_contact": return await this.handleSendContact(args);
- src/client/waha-client.ts:653-679 (helper)Underlying WAHAClient method that makes the HTTP POST request to /api/sendContactVcard to send the contact vCardasync sendContact(params: { chatId: string; contacts: Array<{ vcard: string }>; reply_to?: string; }): Promise<SendMessageResponse> { const { chatId, contacts, reply_to } = params; if (!chatId) { throw new WAHAError("chatId is required"); } if (!contacts || contacts.length === 0) { throw new WAHAError("contacts array is required"); } const body = { chatId, contacts, session: this.session, reply_to, }; return this.request<SendMessageResponse>("/api/sendContactVcard", { method: "POST", body: JSON.stringify(body), }); }