Transcribe WhatsApp voice messages to text using Cloudflare Workers AI (Whisper).
- Receives WhatsApp voice messages via webhook
- Transcribes audio using Cloudflare Workers AI (Whisper large-v3-turbo)
- Replies with the transcription text
- Supports audio up to 10 minutes
- Automatically splits long transcriptions into multiple messages
Click the "Deploy to Cloudflare Workers" button above, then configure your WhatsApp webhook to point to https://your-worker.workers.dev/webhook.
# Clone the repository
git clone https://github.com/vierja/whatsapp-whisper.git
cd whatsapp-whisper
# Install dependencies
npm install
# Configure secrets
npx wrangler secret put PHONE_NUMBER_ID
npx wrangler secret put VERIFY_TOKEN
npx wrangler secret put WHATSAPP_TOKEN
# Deploy
npm run deployYou need to set three secrets in your Cloudflare Worker:
| Secret | Description |
|---|---|
PHONE_NUMBER_ID |
Your WhatsApp Phone Number ID from Meta Business |
VERIFY_TOKEN |
A secret token you create for webhook verification |
WHATSAPP_TOKEN |
Your WhatsApp System User Access Token |
Setting up the WhatsApp Business API requires several steps in the Meta Business UI. See docs/whatsapp-setup-guide.md for a complete guide.
- Create a Meta App at developers.facebook.com
- Add the WhatsApp product to your app
- Add and verify a phone number
- Create a System User and generate an access token
- Configure your webhook URL to
https://your-worker.workers.dev/webhook
We provide scripts to automate the API-based setup steps:
# Run the setup script (after completing UI steps)
./scripts/whatsapp-setup.sh
# Check your WhatsApp API status
./scripts/whatsapp-status.sh# Run locally with remote AI
npm run dev
# Run fully local (no AI)
npm run dev:local- User sends a voice message to your WhatsApp number
- WhatsApp sends a webhook to your Cloudflare Worker
- Worker downloads the audio from WhatsApp's servers
- Worker transcribes the audio using Whisper via Workers AI
- Worker sends the transcription back as a text reply
- Audio must be under 10 minutes (~3MB)
- Currently set to transcribe Spanish (
language: "es") - Only processes audio messages; replies with a message for other types
Edit src/index.ts and change the language parameter:
const transcription = await env.AI.run("@cf/openai/whisper-large-v3-turbo", {
audio: base64Audio,
language: "en", // Change to your language code
});Edit the message in src/index.ts:
await sendWhatsAppMessage(env, message.from, "Solo acepto audios");MIT