Skip to main content
Glama
wsapi-chat
by wsapi-chat

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
NameRequiredDescriptionDefault
idYesContact ID (phone number with @s.whatsapp.net)
fullNameYesFull name of the contact (max 255 characters)
firstNameYesFirst name of the contact (max 255 characters)

Implementation Reference

  • 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', }; }, };
  • Zod validation schema (createContactSchema) used by the handler's validateInput for input parameters: id, fullName, firstName
    export const createContactSchema = z.object({ id: phoneNumberSchema, fullName: z.string().min(1).max(255), firstName: z.string().min(1).max(255), });
  • Exports contactTools object containing the createContact handler (whatsapp_create_contact) for later registration in the server
    export 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_contact
    private 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 registration
    import { contactTools } from './tools/contacts.js';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wsapi-chat/wsapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server