Skip to main content
Most apps should use Spectrum - it gives you a unified, higher-level API across WhatsApp Business, iMessage, and other platforms. Reach for @photon-ai/whatsapp-business directly only when you need low-level WhatsApp control that Spectrum doesn’t expose.
@photon-ai/whatsapp-business is a TypeScript SDK for the WhatsApp Business API. It connects to our managed gRPC gateway, which fronts Meta’s Cloud API — you get typed message sending, a resumable event stream, and media handling without wiring webhooks yourself.

Installation

Requires Node.js 18+ or Bun.

Credentials

Three values are required. Get them in one of two ways:
Sign up at app.photon.codes, toggle WhatsApp on in your project, finish the guided config, and copy the credentials.Use these directly with createClient, or pass them to spectrum-ts to combine WhatsApp with iMessage and other platforms behind one unified API.

Quick start

createClient

The returned WhatsAppClient exposes three resources:

Disposing the client

The client implements Symbol.asyncDispose, so await using handles teardown automatically:
Or close it explicitly:

Your first echo bot

  • event.type is narrowed to "message" or "status" — only messages get a .message field.
  • InboundContent is a discriminated union; switch on content.type before reading fields.
  • event.message.from is the WhatsApp ID of the sender — pass it straight to send.to.

Reconnection and missed events

The stream reconnects automatically when the connection drops, and fetches any events buffered in the meantime. See Events for cursor management and Error handling for when to retry.