get_analytics
Retrieve messaging analytics including sent, delivered, and read message counts for specified date ranges to monitor WhatsApp Business performance.
Instructions
Get messaging analytics (sent, delivered, read counts) for a date range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | Start date in UNIX timestamp format | |
| end_date | Yes | End date in UNIX timestamp format | |
| granularity | No | Data granularity | DAY |
Implementation Reference
- src/whatsapp-client.ts:262-270 (handler)The actual implementation of the getAnalytics method, which constructs the API request to the WhatsApp Business API.
async getAnalytics(params: { start: string; end: string; granularity: "HALF_HOUR" | "DAY" | "MONTH"; }) { return this.request( `/${this.config.businessAccountId}?fields=analytics.start(${params.start}).end(${params.end}).granularity(${params.granularity})` ); } - src/index.ts:369-387 (registration)Registration of the 'get_analytics' MCP tool, which validates input parameters and calls the wa.getAnalytics handler.
server.tool( "get_analytics", "Get messaging analytics (sent, delivered, read counts) for a date range.", { start_date: z.string().describe("Start date in UNIX timestamp format"), end_date: z.string().describe("End date in UNIX timestamp format"), granularity: z .enum(["HALF_HOUR", "DAY", "MONTH"]) .default("DAY") .describe("Data granularity"), }, async ({ start_date, end_date, granularity }) => executeWithHooks( "get_analytics", { start_date, end_date, granularity }, config, () => wa.getAnalytics({ start: start_date, end: end_date, granularity }) ) );