@corelay/mesh-channels-whatsapp
v0.1.0
Published
WhatsApp Cloud API channel adapter for Corelay Mesh.
Readme
@corelay/mesh-channels-whatsapp
WhatsApp Cloud API channel adapter for Corelay Mesh.
Turns inbound WhatsApp webhooks into Mesh Messages and sends outbound messages via the Cloud API. Framework-agnostic — wire it into Express, Fastify, or a raw Node HTTP server.
Install
npm install @corelay/mesh-channels-whatsappAPI
parseWebhookBody(body: unknown): ParsedInbound[]
Parses the raw Meta webhook JSON payload into structured inbound entries.
toMessage(parsed: ParsedInbound): Message
Converts a parsed inbound entry into a Mesh Message.
handleWebhook(config: HandleWebhookConfig, req: WebhookRequest): WebhookResponse
Full webhook handler. Accepts a config object and a framework-agnostic request, returns a WebhookResponse. Always responds with 200 on POST requests to prevent Meta from retrying delivery.
WhatsAppClient
Sends outbound messages through the Cloud API. Configured with accessToken and defaultPhoneNumberId.
import { WhatsAppClient } from "@corelay/mesh-channels-whatsapp";
const client = new WhatsAppClient({ accessToken: "...", defaultPhoneNumberId: "..." });userPeer(config: UserPeerConfig): Peer
Creates a Peer representing a WhatsApp user. Users are addressed as whatsapp/<phoneNumberE164> (no + prefix).
Setup
- Create a WhatsApp Business app in the Meta Developer Portal.
- Point the webhook URL at your deployment.
- Provide
WHATSAPP_VERIFY_TOKEN,WHATSAPP_ACCESS_TOKEN, andWHATSAPP_PHONE_NUMBER_ID. - Pass requests through to
handleWebhook.
License
MIT © Corelay Ltd
