Experimental
Place a WhatsApp voice call from Go and play a clip
A pure Go library that rings a number from your whatsmeow session and hangs up once the clip is done
Read the docswhatsapp-call
$ ./whatsapp-call call 6281234567890 clip.mp3 calling 6281234567890 with 3.6s of audio call 3EB0C0FFEE00000000000000000000AB: answered=true played=4.92s ended by us
- Offer sentthe call key goes to each device, Signal-encrypted
- Relay readySTUN allocate over a DataChannel
- Phone ringssilent frames every 60 ms
- Answereda short lead-in sound loops
- Clip playsMLow frames, then the outro
- Hung upterminate, then wait for the ack
One function call
It blocks until the call is over and tells you how it went. Go API →
res, err := call.Play(ctx, client, jid, pcm, call.Options{ LeadIn: 3 * time.Second, LeadInSound: loading, // optional, loops during LeadIn OutroSound: chime, // optional, plays after the clip })
- In
- A whatsmeow client
- A phone number or LID
- 16 kHz mono samples
- Out
- Answered or not
- How much played
- Who hung up
Six small packages
Pure Go with no cgo. The codec runs as WebAssembly inside wazero.
- callSignaling over whatsmeow, relay choice, pacing and hang-up
- relaySTUN relay control and a WebRTC DataChannel via pion
- mlowThe MLow encoder, a libopus fork in wasm on wazero
- rtpRTP with the WARP extension and the RTCP cadence
- srtpPer-direction keys, AES-CM and the WARP MI tag
- ssrcStream IDs derived from the call ID and your LID
Read this before you call
Use your own numbers, and a calling number you can afford to lose. Before you start →
- UnofficialSpeaks the protocol the apps use with no official API behind it
- Can breakAny WhatsApp update can change that protocol
- Ban riskThe number that places calls can get banned
- One wayThe callee hears you but their audio isn't decoded
- Codec licenselibopus.wasm is a libopus fork with Meta's MLow extension and an unclear license