The CLI
Link a WhatsApp account and place test calls from the terminal with whatsapp-call.
./whatsapp-call call 6281234567890 clip.mp3whatsapp-call is the manual test tool that ships with the library, in cmd/whatsapp-call. Build it with go build -o whatsapp-call ./cmd/whatsapp-call. It needs ffmpeg on your PATH to decode audio.
Commands
| Command | What it does |
|---|---|
whatsapp-call link | Links the CLI as a WhatsApp device. Writes qr.png to scan from WhatsApp, Linked devices, Link a device. Prints already linked as ... when the session exists. |
whatsapp-call call <phone> <audio file> | Calls <phone> and plays the file once they answer. |
whatsapp-call -text "..." -elevenlabs-key-file <file> call <phone> | Turns the text into speech with ElevenLabs, then calls with it. |
Flags come before the command, the way Go's flag package reads them. <phone> is the number with its country code. A leading + and spaces are dropped.
Flags
| Flag | Default | What it does |
|---|---|---|
-db | whatsapp-call.db | The whatsmeow session database, created by link |
-ring | 1m0s | How long to ring before giving up |
-lead-in | 3s | Pause after the answer, filled with a soft loading sound |
-tempo | 1.17 | ffmpeg atempo applied to the clip. 1 plays it at its own speed |
-text | Speak this text with ElevenLabs instead of playing a file | |
-voice | EXAVITQu4vr4xnSDxMaL | ElevenLabs voice ID. The default is Sarah, a premade voice free plans can use |
-elevenlabs-key-file | File holding the ElevenLabs API key. Needed with -text |
What a call sounds like
- The phone rings for up to
-ring. The CLI sends silent frames meanwhile. - Once the callee answers, a soft two-note blip every 0.75 s plays for
-lead-in, so they have the phone at their ear. - The clip plays once.
- A short descending chime (about 1.3 s) says the call is done.
- After half a second of quiet the CLI hangs up.
The CLI decodes the file with ffmpeg to 16 kHz mono float samples, applying -tempo on the way. Any format ffmpeg reads works, and only the first audio track is used.
Output
calling 6281234567890 with 3.6s of audio
call 3EB0C0FFEE00000000000000000000AB: answered=true played=4.92s ended by uswith ...s of audio: the clip's length after-tempo.answered: whether anyone picked up.played: how much went out after the answer, the clip plus the closing chime.ended by:uswhen the CLI hung up after the clip,calleewhen they hung up or declined (with their reason after it),timeoutwhen nobody answered.
Progress, like ringing, relay ready and answered, goes to stderr.
Text to speech
With -text, the CLI sends the text to ElevenLabs (model eleven_multilingual_v2), saves the mp3 as whatsapp-call-tts.mp3 in your temp folder, and plays that. The key is read from the file so it never shows up in your shell history or the process list.
./whatsapp-call -text "Hello, this is a test call" -elevenlabs-key-file ~/elevenlabs.key call 6281234567890Errors
| Message | What to do |
|---|---|
not linked: run whatsapp-call link first | Run link with the same -db. |
WhatsApp didn't connect within 30 s | Check the network, then that the device still shows under Linked devices on the phone. |
-text needs -elevenlabs-key-file | Pass the key file. |
ffmpeg: ... | Install ffmpeg, or check that the file has an audio track. |
call: no LID known for ... (message them first) | Send the number a WhatsApp message from the calling account, then call again. |
call: no IPv4 relay to dial | The server offered no IPv4 relay, or none could be dialed. Try again. |