-
c16d4b5: feat: add onRaw handler with WebhookField filter support
Add
onRaw(handler, fields?)toWebhookProcessorfor bypassing raw Meta webhook payloads to external URLs while preserving the originalWebhookPayloadinterface.When
fieldsis provided, only matchingentry.changesentries are forwarded; if no changes match, the handler is skipped entirely.Add
WebhookFieldas-const object andWebhookFieldTypeunion type for type-safe field filtering, covering all 32 supported webhook fields.import { WebhookField } from "meta-cloud-api"; processor.onRaw( async (whatsapp, payload) => { await fetch("https://your-service.com/webhook", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), }); }, [WebhookField.AccountUpdate, WebhookField.Calls] );
-
e3df37e: feat: add Calls webhook types
Add TypeScript interfaces for the
callswebhook field, based on the official Meta webhook sample payload. IncludesCallEntrywith all lifecycle event types (connect, call_status, media_update, terminate),CallsValuewith metadata and contacts, and supporting enums. -
a84749c: feat: add Group API webhook types
Add TypeScript interfaces for all four group lifecycle webhook fields:
group_lifecycle_update(group_create, group_delete)group_participants_update(add, remove, join requests)group_settings_update(subject, description, profile picture)group_status_update(suspend, suspend_cleared)
All types are based on official Meta webhook sample payloads.
-
4ad4c46: feat: add Marketing webhook types
Add TypeScript interfaces for marketing-related webhook fields:
automatic_events: Meta ML-detected lead gen / purchase events from Click-to-WhatsApp ads (requires Embedded Signup opt-in)tracking_events: Message delivery and click tracking events, withevents[]array containingevent_name,timestamp, andtracking_data
-
3fb48f0: feat: add Messaging handover webhook types
Add TypeScript interfaces for messaging handover webhook fields:
messaging_handovers: WhatsApp handover protocol events withcontrol_passed,sender, andrecipientfieldsstandby: Delivered when the app is not the current thread owneruser_preferences: User opt-out events withuser_preferences[]array containing category, value ("stop"), and contact profile info
-
875a862: feat: add Partner and Payment webhook types
Add TypeScript interfaces for partner and payment webhook fields:
partner_solutions: Partner solution lifecycle events withevent,solution_id, andsolution_statuspayment_configuration_update: Payment provider configuration changes with provider name, MID, status, and timestamps
-
81e46eb: feat: add handlers for 17 missing webhook fields
Wire up handlers for all previously unsupported webhook fields in
WebhookProcessorandprocessWebhookMessages:Groups: group_lifecycle_update, group_participants_update, group_settings_update, group_status_update
Calls: calls
Account: account_settings_update
Business: business_status_update
Marketing: automatic_events, tracking_events
Messaging: message_echoes, messaging_handovers, standby, user_preferences
Template: message_template_components_update, template_correct_category_detection
Partner/Payment: partner_solutions, payment_configuration_update
Each field has a corresponding on*() registration method and type-safe handler/processed types.
-
50725c0: feat: expand existing webhook type definitions
Update existing webhook type files based on official Meta API docs:
account.ts: Expandaccount_updatewith 10 new event types (ACCOUNT_OFFBOARDED, PARTNER_CLIENT_CERTIFICATION_STATUS_UPDATE, VOLUME_BASED_PRICING_TIER_UPDATE, etc.) and addaccount_settings_updatewith phone number calling configurationbusiness.ts: Addbusiness_status_updatewebhook typemessageEchoes.ts: Addmessage_echoestypes (distinct fromsmb_message_echoes)template.ts: Addmessage_template_components_updateandtemplate_correct_category_detectionwebhook types
- Add comprehensive JSDoc with @see reference links to all 17 API modules, fix type safety issues (as any casts, showTypingIndicator status, MediaApi method call, config NaN), and add missing WABA account fields from official Graph API reference.
-
8174951: # v2.0.0 - Complete Documentation Site & Production Examples
This major release introduces a comprehensive documentation website, production-ready examples, and improved project structure with pnpm workspace.
- Workspace Migration: Project now uses pnpm workspace for better monorepo management
- Examples Structure:
express-examplerenamed toexpress-simplefor clarity
- Getting Started: Installation, quick start, configuration guides
- API Reference: Complete documentation for all 17 API modules
- Webhook Guides: Express, Next.js, and custom webhook implementations
- Framework Guides: Express, Next.js App/Pages Router integration
- Type Reference: TypeScript types, enums, and interfaces
- Built with Astro + Starlight theme
- Full-text search with Pagefind
- Mobile responsive design
- Complete customer support bot with conversation flows
- PostgreSQL database with Prisma ORM
- Redis session management
- BullMQ background job processing
- Comprehensive error handling and logging
- Full test suite (unit, integration, e2e)
- Docker deployment ready
- 57 files, 4,500+ lines of production code
- Automated documentation deployment to Vercel
- Example validation on pull requests
- Type checking and build verification
- pnpm workspace for efficient dependency management
- Examples use
workspace:*protocol for local SDK linking - Shared tooling configuration across packages
Visit the new documentation site at https://meta-cloud-api.site
express-simple: Basic Express.js integrationexpress-production: Production-ready example with full featuresnextjs-app-router-example: Next.js 15 App Routernextjs-page-router-example: Next.js Pages Router
Co-Authored-By: Claude Opus 4.5 [email protected]
- a926c52: Improve PKCS#1 private key handling with automatic format conversion
- Add automatic conversion of PKCS#1 format keys to PKCS#8 format when decryption fails
- Support legacy keys encrypted with DES-EDE3-CBC algorithm by converting to AES-256-CBC
- Export additional encryption utilities:
decryptFlowRequestandencryptFlowResponse - Enhance error logging with detailed format detection and conversion attempt tracking
- Improve error messages with helpful instructions for manual key conversion
-
c0ed913: Implement comprehensive webhook field support with type-safe handlers
Add full support for Meta Cloud API webhook fields with granular field-level type definitions and handler registration. This update introduces a robust webhook processing system that allows developers to handle specific webhook fields (messages, account updates, flows, etc.) with complete type safety.
Features:
- Add WebhookProcessor class for field-specific handler registration and processing
- Add comprehensive type definitions for all webhook fields:
- Account updates (account_update, account_alerts)
- App state sync (app_state_sync)
- Business updates (business_capability_update, business_account_review_update, business_status_update)
- Flows (flows)
- Message history (history)
- Messages (messages)
- Message echoes (message_echoes)
- Phone number updates (phone_number_name_update, phone_number_quality_update)
- Security (security)
- Status updates (statuses)
- Template updates (message_template_status_update, template_category_update)
- Add webhook field type guards and utilities for runtime validation
- Add example implementations for account updates, flows, and message history handlers
Type System Improvements:
- Organize webhook types into modular files by field category
- Add detailed TypeScript interfaces for all webhook notification structures
- Add proper type exports and re-exports for better developer experience
- Improve type safety with discriminated unions for different field types
Examples:
- Add Express example demonstrating field-specific webhook handler registration
- Add handler implementations for common webhook scenarios
- Show best practices for processing different webhook field types
Breaking Changes: None - this is an additive change that maintains backward compatibility with existing webhook handlers.
- 219650b: Improve Flow encryption utilities with validation and better logging
- Add validation for required environment variables (FLOW_API_PRIVATE_PEM, FLOW_API_PASSPHRASE) in decryptFlowRequest
- Enhance all log messages with function context prefixes ([generateEncryption], [decryptFlowRequest], [encryptFlowResponse])
- Remove sensitive information (PEM preview) from error logs for better security
- Clean up and standardize logging messages throughout encryption utilities
-
0677594: ## Features
Add 13 specialized handler methods for better type safety and developer experience:
onText(),onImage(),onVideo(),onAudio(),onDocument(),onSticker()onInteractive(),onButton(),onLocation(),onContacts()onReaction(),onOrder(),onSystem()
These methods provide automatic type narrowing, eliminating the need for optional chaining.
Example:
bot.processor.onText(async (whatsapp, processed) => { const { message } = processed; console.log(message.text.body); // ✅ No optional chaining needed! });
Add
messageIdproperty toProcessedMessagetype for consistent message ID access across all message types:- Automatically extracts ID from the correct location based on message type
- For most messages: uses
message.id - For interactive/button replies (e.g.,
nfm_reply): usesmessage.context.id
Example:
bot.processor.onMessagePreProcess(async (whatsapp, processed) => { // Works for all message types, including nfm_reply await whatsapp.messages.markAsRead({ messageId: processed.messageId }); });
Add support for WhatsApp Flow responses (
nfm_replymessage type):- New
InteractiveNfmReplyMessagetype for Flow response messages - Proper type definitions for Flow webhook data
- Update README with comprehensive examples of specialized handlers
- Add examples showing messageId usage across different message types
- Document TypeScript discriminated union approach for type narrowing
console.log("🚀 ~ ## Features
Add 13 specialized handler methods for better type safety and developer experience:
onText(),onImage(),onVideo(),onAudio(),onDocument(),onSticker()onInteractive(),onButton(),onLocation(),onContacts()onReaction(),onOrder(),onSystem()
These methods provide automatic type narrowing, eliminating the need for optional chaining.
Example:
bot.processor.onText(async (whatsapp, processed) => { const { message } = processed; console.log(message.text.body); // ✅ No optional chaining needed! });
Add
messageIdproperty toProcessedMessagetype for consistent message ID access across all message types:- Automatically extracts ID from the correct location based on message type
- For most messages: uses
message.id - For interactive/button replies (e.g.,
nfm_reply): usesmessage.context.id
Example:
bot.processor.onMessagePreProcess(async (whatsapp, processed) => { // Works for all message types, including nfm_reply await whatsapp.messages.markAsRead({ messageId: processed.messageId }); });
Add support for WhatsApp Flow responses (
nfm_replymessage type):- New
InteractiveNfmReplyMessagetype for Flow response messages - Proper type definitions for Flow webhook data
- Update README with comprehensive examples of specialized handlers
- Add examples showing messageId usage across different message types
- Document TypeScript discriminated union approach for type narrowing :", ## Features
Add 13 specialized handler methods for better type safety and developer experience:
onText(),onImage(),onVideo(),onAudio(),onDocument(),onSticker()onInteractive(),onButton(),onLocation(),onContacts()onReaction(),onOrder(),onSystem()
These methods provide automatic type narrowing, eliminating the need for optional chaining.
Example:
bot.processor.onText(async (whatsapp, processed) => { const { message } = processed; console.log(message.text.body); // ✅ No optional chaining needed! });
Add
messageIdproperty toProcessedMessagetype for consistent message ID access across all message types:- Automatically extracts ID from the correct location based on message type
- For most messages: uses
message.id - For interactive/button replies (e.g.,
nfm_reply): usesmessage.context.id
Example:
bot.processor.onMessagePreProcess(async (whatsapp, processed) => { // Works for all message types, including nfm_reply await whatsapp.messages.markAsRead({ messageId: processed.messageId }); });
Add support for WhatsApp Flow responses (
nfm_replymessage type):- New
InteractiveNfmReplyMessagetype for Flow response messages - Proper type definitions for Flow webhook data
- Update README with comprehensive examples of specialized handlers
- Add examples showing messageId usage across different message types
- Document TypeScript discriminated union approach for type narrowing )
-
0bf91c0: ## Features
Add 13 specialized handler methods for better type safety and developer experience:
onText(),onImage(),onVideo(),onAudio(),onDocument(),onSticker()onInteractive(),onButton(),onLocation(),onContacts()onReaction(),onOrder(),onSystem()
These methods provide automatic type narrowing, eliminating the need for optional chaining.
Example:
bot.processor.onText(async (whatsapp, processed) => { const { message } = processed; console.log(message.text.body); // ✅ No optional chaining needed! });
Add
messageIdproperty toProcessedMessagetype for consistent message ID access across all message types:- Automatically extracts ID from the correct location based on message type
- For most messages: uses
message.id - For interactive/button replies (e.g.,
nfm_reply): usesmessage.context.id
Example:
bot.processor.onMessagePreProcess(async (whatsapp, processed) => { // Works for all message types, including nfm_reply await whatsapp.messages.markAsRead({ messageId: processed.messageId }); });
Add support for WhatsApp Flow responses (
nfm_replymessage type):- New
InteractiveNfmReplyMessagetype for Flow response messages - Proper type definitions for Flow webhook data
- Update README with comprehensive examples of specialized handlers
- Add examples showing messageId usage across different message types
- Document TypeScript discriminated union approach for type narrowing
-
49d462f: Consolidate encryption utilities and clean up verbose logging
- Merge generateEncryption into flowEncryptionUtils for better code organization
- Remove duplicate encryption functions from webhookUtils
- Remove verbose debug logging from webhook processing
-
49d462f: Add dedicated status handler with improved type system
New Feature:
- Add
onStatus(handler)method to WebhookProcessor for handling status updates - Introduce new types:
ProcessedMessage,ProcessedStatus,StatusHandler
Breaking Change:
MessageTypesEnum.Statusesis now deprecated- Using
onMessage(MessageTypesEnum.Statuses, handler)will throw an error - Migrate to
onStatus(handler)for better type safety
Migration:
// Before (deprecated) processor.onMessage(MessageTypesEnum.Statuses, (whatsapp, message) => { // handle status }); // After (recommended) processor.onStatus((whatsapp, processed) => { // processed.status: StatusWebhook console.log(processed.status); });
- Add
-
bc8b13d: Add Conversational Automation API support for WhatsApp Business Phone Numbers
This release adds support for configuring conversational components on WhatsApp Business phone numbers:
- Welcome Messages: Configure automatic welcome messages for first-time users
- Ice Breakers (Prompts): Set up to 4 tappable prompts (max 80 characters each) to help users start conversations
- Commands: Define up to 30 slash commands (max 32 chars name, 256 chars description) for easy user interactions
New API methods:
phoneNumber.setConversationalAutomation()- Configure conversational components (POST)phoneNumber.getConversationalAutomation()- Retrieve current configuration (GET)
New TypeScript types:
ConversationalAutomationRequest- Request payload for configurationConversationalAutomationResponse- Response with current settingsConversationalCommand- Command configuration objectConversationalPrompt- Ice breaker prompt string
For more details, see: https://developers.facebook.com/docs/whatsapp/cloud-api/phone-numbers/conversational-components
-
34c7fc6: Add getThroughput API for phone number throughput monitoring
- Add
getThroughput()method to PhoneNumberApi class - Returns current throughput level (STANDARD, HIGH, or NOT_APPLICABLE)
- Add comprehensive unit tests for throughput API
- Add example file demonstrating throughput monitoring and eligibility checking
- Support for checking phone number messaging capacity (80 mps default, up to 1,000 mps)
- Add
-
8ccdaa4: Add block user API for managing blocked WhatsApp users
- Add
blockUsersAPI with block, unblock, and list methods - Support for blocking/unblocking users by phone number or WhatsApp ID
- Pagination support for listing blocked users
- Comprehensive unit tests and examples included
- Add
-
8144883: Enhanced type exports for improved type inference in onMessage webhook handler
Changes:
- Exported all specific message type interfaces (TextMessage, ImageMessage, VideoMessage, etc.) from the main package
- Exported discriminated union types for webhook values (MessageWebhookValue, StatusWebhookValue, ErrorWebhookValue)
- Exported complete webhook payload types (WebhookValue, StatusWebhook, WebhookPayload)
Benefits:
- Better TypeScript IntelliSense when working with
onMessagecallback parameters - Proper type narrowing based on message type discriminators
- Users can now import and use specific message types for type annotations
- Improved developer experience with autocomplete for all message properties
Example:
import { TextMessage, ImageMessage, WhatsAppMessage } from "meta-cloud-api"; client.onMessage((message: WhatsAppMessage) => { if (message.type === "text") { // TypeScript now knows this is a TextMessage console.log(message.text.body); } else if (message.type === "image") { // TypeScript now knows this is an ImageMessage console.log(message.image.id); } });
Migration: No breaking changes - existing code continues to work. The new exports simply provide better type support for developers who want explicit type annotations.
-
82665d1: remove builder pattern for ease
-
0ebca06: Improve webhook types based on WhatsApp official documentation
Changes:
- Added discriminated union types for webhook values (MessageWebhookValue, StatusWebhookValue, ErrorWebhookValue)
- Added specific message type interfaces for all WhatsApp message types (Text, Image, Video, Audio, Document, Sticker, Interactive, Button, Location, Contacts, Reaction, Order, System, Unsupported)
- Added context types for forwarded messages, product inquiries, and interactive replies (ForwardedContext, ProductContext, ReplyContext)
- Added Click to WhatsApp ad referral tracking support (ReferralInfo)
- Added support for group messages with group_id field
- Added Unsupported message type to MessageTypesEnum
- Interactive messages now properly discriminated between list_reply and button_reply
Migration: No changes required - existing code continues to work as before. The new types provide better IntelliSense and type checking internally.
-
6c8d8df: # Flow Webhook Handler Enhancements
Introduced granular Flow webhook handler registration with support for three distinct flow types:
- Ping (Health Check): Automatic endpoint health verification from WhatsApp
- Error Notification: Error notifications from WhatsApp client
- Data Exchange: Interactive flow data exchanges with end users
Users can now register handlers for specific flow types using
FlowTypeEnum.Ping,FlowTypeEnum.Error, andFlowTypeEnum.Change, enabling more organized and maintainable code structure.Ping and Error handlers are now automatically handled by default if not explicitly registered. This significantly reduces boilerplate code - users only need to register the
FlowTypeEnum.Changehandler for their business logic. The library automatically returns standard-compliant responses for Ping and Error requests, while still allowing custom handlers to be registered when needed.Eliminated all
anytypes from webhook handlers, replacing them with explicitWebhookResponsereturn types:handleGet,handlePost, andhandleFlownow returnPromise<WebhookResponse>- Improved error handling with proper type propagation
- Better IntelliSense and compile-time type checking
Renamed framework-specific handlers for better clarity:
nextjsWebhookHandler→nextjsPagesWebhookHandler(Next.js Pages Router)nextjsAppWebhookHandlerremains unchanged (Next.js App Router)expressWebhookHandlerremains unchanged
Migration:
// Before import { nextjsWebhookHandler } from "meta-cloud-api"; // After import { nextjsPagesWebhookHandler } from "meta-cloud-api";
Removed
webhookHandleraliases from all framework handlers to prevent confusion. Each framework now has a single, explicit handler name.Removed public exports of flow type guard functions (
isFlowPingRequest,isFlowErrorRequest,isFlowDataExchangeRequest). These are now internal implementation details as the library automatically handles flow type detection.Fixed "API handler should not return a value" error in Next.js Pages Router. Handlers now properly send responses without returning values, conforming to Next.js API route specifications.
Enhanced error handling across all webhook handlers:
- Properly throw errors instead of returning response objects in catch blocks
- Added response sending before throwing to ensure clients receive error responses
- Consistent error response format across all frameworks
Cleaned up all
console.logstatements from production code, reducing noise in production environments while maintaining proper error logging through the Logger utility.Renamed internal directory structure for consistency:
src/core/webhook/frameworks/nextjs/→src/core/webhook/frameworks/nextjs-page/- Corresponding file renames:
nextjs.ts→nextjs-page.ts
Before:
flowHandler.processor.onFlow(FlowTypeEnum.Ping, createFlowPingResponse); flowHandler.processor.onFlow(FlowTypeEnum.Error, createFlowErrorResponse); flowHandler.processor.onFlow( FlowTypeEnum.Change, async (_whatsapp, request) => { // Custom logic } );
After:
// Ping and Error are automatically handled! flowHandler.processor.onFlow( FlowTypeEnum.Change, async (_whatsapp, request) => { // Only implement your business logic } );
Reduced necessary imports:
// Before import { createFlowErrorResponse, createFlowPingResponse, isFlowPingRequest, isFlowErrorRequest, nextjsWebhookHandler, } from "meta-cloud-api"; // After import { nextjsPagesWebhookHandler } from "meta-cloud-api";
Refined handler selection priority for better predictability:
For Ping and Error types:
- Use registered specific handler if available
- Fallback to automatic default handler (does NOT fallback to
Allhandler)
For Data Exchange (Change) type:
- Use registered
Changehandler if available - Fallback to
Allhandler - Return 404 if no handler found
This ensures Ping and Error always receive proper responses while giving developers flexibility for data exchange handling.
- Enhanced type safety throughout the webhook processing pipeline
- Improved code organization and readability
- Better separation of concerns between framework-specific and core logic
- Consistent error handling patterns across all implementations
- 34f780a: add missing debug check on logger class and parsing object correctly with inspect
- df83318: implement nextjs app router webhook handler and refactoring architecture of handlers
- bcccf06: export flow related types