whatsapp_create_contact
Create a new WhatsApp contact by providing phone number and name details. This tool adds contacts to your WhatsApp account for messaging and communication purposes.
Instructions
Create a new WhatsApp contact.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Contact ID (phone number with @s.whatsapp.net) | |
| fullName | Yes | Full name of the contact (max 255 characters) | |
| firstName | Yes | First name of the contact (max 255 characters) |
Implementation Reference
- src/tools/contacts.ts:70-108 (handler)Full ToolHandler definition and implementation for 'whatsapp_create_contact', including name, description, inputSchema, and the async handler that validates input with createContactSchema and posts to wsapiClient('/contacts')export const createContact: ToolHandler = { name: 'whatsapp_create_contact', description: 'Create a new WhatsApp contact.', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, fullName: { type: 'string', description: 'Full name of the contact (max 255 characters)', }, firstName: { type: 'string', description: 'First name of the contact (max 255 characters)', }, }, required: ['id', 'fullName', 'firstName'], }, handler: async (args: any) => { const input = validateInput(createContactSchema, args); logger.info('Creating contact', { id: input.id, fullName: input.fullName, }); await wsapiClient.post('/contacts', input); logger.info('Contact created successfully', { id: input.id }); return { success: true, message: 'Contact created successfully', }; }, };
- src/validation/schemas.ts:177-181 (schema)Zod validation schema (createContactSchema) used by the handler's validateInput for input parameters: id, fullName, firstNameexport const createContactSchema = z.object({ id: phoneNumberSchema, fullName: z.string().min(1).max(255), firstName: z.string().min(1).max(255), });
- src/tools/contacts.ts:247-255 (registration)Exports contactTools object containing the createContact handler (whatsapp_create_contact) for later registration in the serverexport const contactTools = { getContacts, getContact, createContact, updateContact, getContactPicture, getContactBusinessProfile, subscribeToContactPresence, };
- src/server.ts:53-79 (registration)Server method that registers all tools from collections like contactTools into this.tools Map, including whatsapp_create_contactprivate setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
- src/server.ts:16-16 (registration)Import of contactTools containing whatsapp_create_contact for server registrationimport { contactTools } from './tools/contacts.js';