Trigger Official WhatsApp Messages From Cloud Firestore Writes
import { getFirestore, collection, addDoc } from "firebase/firestore";
const db = getFirestore();
// Writing a document automatically triggers a WhatsApp template message
await addDoc(collection(db, "whatsapp_outbox"), {
to: "+16317471111",
template: {
name: "order_confirmation",
language: "en",
components: [
{
type: "body",
parameters: [
{ type: "text", text: "Alex" },
{ type: "text", text: "ORD-9842" }
]
}
]
}
});Simple Configuration, Full Delivery Observability
Extension Parameters
WHATSBOX_API_KEYWorkspace API key created under Settings > API Keys in WhatsBox (stored securely as a Firebase secret).
WHATSAPP_CHANNEL_IDInternal WhatsApp channel ID copied from WhatsApp Numbers in your WhatsBox workspace.
COLLECTION_PATHThe Cloud Firestore collection watched for new message documents (e.g., whatsapp_outbox).
Automatic Document Status Fields
delivery_statusAutomatically set to PENDING, SUCCESS, or ERROR as the Cloud Function executes.
whatsbox_message_idUnique WhatsBox / WhatsApp tracking ID for correlating with delivery webhooks.
processed_atFirestore server timestamp recording exact processing time.
errorActionable diagnostic message logged if dispatch fails (e.g., invalid number or inactive key).
Ship Serverless WhatsApp Notifications in 3 Steps
Install via Firebase CLI
Run firebase ext:install whatsb/firestore-send-whatsapp-message against your Blaze-plan Firebase project.
Add API Key, Channel & Collection
Provide WHATSBOX_API_KEY, WHATSAPP_CHANNEL_ID, and COLLECTION_PATH, and secure writes with Firestore Security Rules.
Write Documents to Send WhatsApp
Any addDoc() write into your watched collection dispatches an approved WhatsApp template and writes delivery_status right back.