waha_send_location
Send location coordinates to WhatsApp chats using latitude and longitude data, enabling location sharing in conversations.
Instructions
Send location coordinates to a WhatsApp chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) | |
| latitude | Yes | Latitude coordinate | |
| longitude | Yes | Longitude coordinate | |
| title | No | Optional title/name for the location | |
| replyTo | No | Optional message ID to reply to |
Implementation Reference
- src/index.ts:1722-1759 (handler)Handler function that executes the waha_send_location MCP tool. Validates input parameters, calls the underlying WAHAClient.sendLocation method, formats the success response using formatSendMessageSuccess, and returns structured MCP content with location details.private async handleSendLocation(args: any) { const chatId = args.chatId; const latitude = args.latitude; const longitude = args.longitude; const title = args.title; const replyTo = args.replyTo; if (!chatId) { throw new Error("chatId is required"); } if (latitude === undefined || longitude === undefined) { throw new Error("latitude and longitude are required"); } const response = await this.wahaClient.sendLocation({ chatId, latitude, longitude, title, reply_to: replyTo, }); const formattedResponse = formatSendMessageSuccess( chatId, response.id, response.timestamp ); return { content: [ { type: "text", text: `${formattedResponse}\nLocation: ${latitude}, ${longitude}${title ? `\nTitle: ${title}` : ''}`, }, ], }; }
- src/index.ts:424-452 (schema)Input schema and metadata definition for the waha_send_location tool, returned by the ListToolsRequestSchema handler.name: "waha_send_location", description: "Send location coordinates to a WhatsApp chat.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, latitude: { type: "number", description: "Latitude coordinate", }, longitude: { type: "number", description: "Longitude coordinate", }, title: { type: "string", description: "Optional title/name for the location", }, replyTo: { type: "string", description: "Optional message ID to reply to", }, }, required: ["chatId", "latitude", "longitude"], }, },
- src/index.ts:1083-1084 (registration)Registration/dispatch case in the CallToolRequestSchema handler that routes calls to the waha_send_location tool to its handler function.case "waha_send_location": return await this.handleSendLocation(args);
- src/client/waha-client.ts:617-647 (helper)WAHAClient.sendLocation helper method that performs the actual HTTP POST request to WAHA API endpoint /api/sendLocation to send the location message.async sendLocation(params: { chatId: string; latitude: number; longitude: number; title?: string; reply_to?: string; }): Promise<SendMessageResponse> { const { chatId, latitude, longitude, title, reply_to } = params; if (!chatId) { throw new WAHAError("chatId is required"); } if (latitude === undefined || longitude === undefined) { throw new WAHAError("latitude and longitude are required"); } const body = { chatId, latitude, longitude, title, session: this.session, reply_to, }; return this.request<SendMessageResponse>("/api/sendLocation", { method: "POST", body: JSON.stringify(body), }); }