townkrier-whatsapp-common
v1.0.0-alpha.1
Published
Common classes and interfaces for WhatsApp channels in Townkrier
Readme
townkrier-whatsapp-common
Common interfaces and base classes for WhatsApp channels in the TownKrier notification system.
Overview
This package provides the shared foundation for all WhatsApp adapters in TownKrier. It includes:
WhatsAppChannel- Abstract base class for WhatsApp implementationsWhatsAppRequest- Interface for WhatsApp message requestsWhatsAppResponse- Interface for WhatsApp message responses
Installation
npm install townkrier-whatsapp-common townkrier-core
# or
pnpm add townkrier-whatsapp-common townkrier-coreUsage
This package is typically used by WhatsApp adapter implementations. For end users, you should use specific adapter packages like:
Interfaces
WhatsAppRequest
interface WhatsAppRequest {
to: {
phone: string; // Phone number in international format (e.g., "+1234567890")
};
text: string; // Message content
[key: string]: any; // Additional provider-specific options
}WhatsAppResponse
interface WhatsAppResponse {
messageId: string; // Provider's message ID
status: NotificationStatus; // SENT, FAILED, etc.
sentAt: Date; // Timestamp when message was sent
rawResponse?: any; // Raw response from provider (optional)
}Contributing
When creating new WhatsApp adapters, extend the WhatsAppChannel class:
import { WhatsAppChannel, WhatsAppRequest, WhatsAppResponse } from 'townkrier-whatsapp-common';
export class MyWhatsAppAdapter extends WhatsAppChannel {
async send(request: WhatsAppRequest): Promise<WhatsAppResponse> {
// Implementation here
}
}License
MIT
