whatsapp_create_contact
Create a new WhatsApp contact by providing phone number, full name, and first name to add to your WhatsApp account.
Instructions
Create a new WhatsApp contact.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| firstName | Yes | First name of the contact (max 255 characters) | |
| fullName | Yes | Full name of the contact (max 255 characters) | |
| id | Yes | Contact ID (phone number with @s.whatsapp.net) |
Implementation Reference
- src/tools/contacts.ts:70-108 (handler)Full ToolHandler implementation for 'whatsapp_create_contact', including inputSchema, validation using createContactSchema, logging, API call to wsapiClient.post('/contacts'), and success response.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 schema used for validating input in the whatsapp_create_contact handler.export const createContactSchema = z.object({ id: phoneNumberSchema, fullName: z.string().min(1).max(255), firstName: z.string().min(1).max(255), });
- src/server.ts:57-79 (registration)Registration logic in setupToolHandlers() that imports and registers all tools from contactTools (including whatsapp_create_contact) into the server's tools Map.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`); }