Skip to content

vierja/whatsapp_whisper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsApp Whisper

Transcribe WhatsApp voice messages to text using Cloudflare Workers AI (Whisper).

Deploy to Cloudflare Workers

Features

  • 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

Quick Start

Option 1: One-Click Deploy

Click the "Deploy to Cloudflare Workers" button above, then configure your WhatsApp webhook to point to https://your-worker.workers.dev/webhook.

Option 2: Manual Deploy

# 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 deploy

Configuration

You 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

WhatsApp Setup

Setting up the WhatsApp Business API requires several steps in the Meta Business UI. See docs/whatsapp-setup-guide.md for a complete guide.

Quick Overview

  1. Create a Meta App at developers.facebook.com
  2. Add the WhatsApp product to your app
  3. Add and verify a phone number
  4. Create a System User and generate an access token
  5. Configure your webhook URL to https://your-worker.workers.dev/webhook

Helper Scripts

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

Development

# Run locally with remote AI
npm run dev

# Run fully local (no AI)
npm run dev:local

How It Works

  1. User sends a voice message to your WhatsApp number
  2. WhatsApp sends a webhook to your Cloudflare Worker
  3. Worker downloads the audio from WhatsApp's servers
  4. Worker transcribes the audio using Whisper via Workers AI
  5. Worker sends the transcription back as a text reply

Limitations

  • 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

Customization

Change Language

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
});

Change Response for Non-Audio Messages

Edit the message in src/index.ts:

await sendWhatsAppMessage(env, message.from, "Solo acepto audios");

License

MIT

About

Host your own Whatsapp Audio to Text account.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors