WhatsApp Cloud API

Drop-in Convex component for WhatsApp Cloud API that handles message sending, receiving, delivery tracking, and conversation threading with reactive queries.

Installation

npm install convex-whatsapp

About WhatsApp Cloud API

A Convex component that wraps the WhatsApp Cloud API to enable messaging functionality within your Convex application. It provides reactive message handling, delivery tracking, and conversation management through Convex functions and database integration. The component eliminates the need to manually handle WhatsApp webhook integrations and API authentication.

Benefits

Use cases

how to send WhatsApp messages from Convex backend

The convex-whatsapp component provides a send() action that calls the WhatsApp Cloud API directly from your Convex functions. It supports text, template, media, and interactive button messages with automatic phone number normalization and error handling.

WhatsApp webhook integration with Convex

This component automatically handles WhatsApp webhook verification and ingestion, storing all inbound messages in Convex tables. You can register callback functions that get scheduled whenever new messages arrive, with full Meta signature verification built-in.

track WhatsApp message delivery status in real time

The component automatically updates message status from queued to sent, delivered, read, or failed based on Meta webhook notifications. All status changes are stored in Convex tables and can be queried reactively in your UI.

manage WhatsApp conversations with unread counts

Messages are automatically threaded into conversations by phone number with unread counts and last-message previews. The component provides queries to list conversations, get message history, and mark conversations as read.

Frequently asked questions

Does convex-whatsapp handle message retry logic?

The convex-whatsapp component intentionally does not include retry logic. Failed messages are stored with status 'failed' and the component throws typed errors with Meta's error codes. For retries, the docs recommend using @convex-dev/workflow to build durable retry workflows with proper backoff handling.

What WhatsApp message types are supported?

The convex-whatsapp component supports text messages, template messages (HSM), media messages (image, document, audio, video), and interactive messages (buttons and lists). All message types work through the same send() action with type-safe parameters.

How do I handle inbound WhatsApp messages?

Register an inbound message handler using registerInboundHandler() with a Convex function handle. The convex-whatsapp component will automatically schedule your function whenever new messages arrive, passing the stored message ID for processing.

Does this component work with WhatsApp Business API?

Yes, the convex-whatsapp component integrates with the WhatsApp Cloud API from Meta (formerly Facebook). It requires a WhatsApp Business Account, phone number ID, and access token from Meta Business Manager to send and receive messages.

Links