Skip to main content
The WhatsApp Cloud API adapter only translates: it checks the signature of Meta’s webhook, extracts each message with the customer’s handle and the item ready to record, and records the agent’s reply from the send API’s answer. It never sends a message: your code talks to the Graph API.

Install

The TypeScript integration is in @niadra/sdk on npm.

The five primitives

subscribe() (Python) and whatsAppChallenge() (TypeScript) answer Meta’s subscription challenge on the GET.

Minimal example

The same code is in examples/whatsapp_webhook.py and examples/whatsapp-cloud.ts. The flush() after record() makes the turn, and the V1 it proves, land before the first read.

Limits

  • The adapter never sends a message nor calls the Graph API; it translates the webhook and records what your code sent.
  • Media arrives as a reference (id, MIME type, SHA-256): download the bytes from the Graph API, hand them to upload_media() and pass the result as upload= (with your transcript= of a voice note). The text of a PDF, an image or an Office file (DOCX, XLSX, PPTX) is read inside the cell only, and only when the space lists the type in media.extract_text_from; the type comes from the bytes, never from the declared MIME type. All reading happens in the models server, in one child process per document, one at a time: the PDF’s text layer, and OCR (RapidOCR with the PP-OCRv6 small recognizer) of the image, scaled down, and of each scanned PDF page, rendered at 200 dpi; a macro-enabled Office file is refused. A file that fails (413 or 422) is treated as a file without text, and no file leaves the region. The text keeps its line breaks, passes the redactor before extraction and becomes a derived turn.
  • Each WhatsAppMessage carries the wa_id and, for a WhatsApp username, the business-scoped user id (BSUID); statuses and other webhook fields are left out.
  • Tested with public payloads in Meta’s format and signatures computed in the test; no Meta account is needed.

Next steps

WhatsApp agents

identity by number, V1 from the channel and the turn the other agents read.

Twilio

WhatsApp and SMS through Twilio, with the same design.