feat: add call answering, outgoing calls and audio injection#201825
Open
alpersamur3 wants to merge 1 commit into
Open
feat: add call answering, outgoing calls and audio injection#201825alpersamur3 wants to merge 1 commit into
alpersamur3 wants to merge 1 commit into
Conversation
Author
|
Heads-up: I've built video support on top of this, in a follow-up branch (
Verified live end-to-end (portrait/landscape, mid-call source + resolution changes, video + injected audio together), including headless and after a cold restart. Once this PR is merged I'll rebase that branch onto |
adds the ability to answer incoming calls, place outgoing calls and inject
audio into an active call, plus fixes that make call handling work on
current WhatsApp Web.
call:
- accept() answers a call (audio only by default, even for video calls)
- end() hangs up an ongoing call
- playAudio(media) streams a MessageMedia/base64 audio clip to the other party
- isConnected() reports whether the other party has answered
client:
- call(chatId, { video, waitForAnswer, answerTimeout }) places an outgoing call
- getActiveCall() returns the ongoing call, if any
fixes:
- Incoming "call" event: current WhatsApp Web reports calls through
WAWebCallCollection's activeCall attribute; the previous internal-map hook
no longer fires. The map hook is kept as a fallback.
- Call.reject() now goes through the voip stack, which the previous signaling
stanza no longer triggers on current WhatsApp Web.
audio is captured through a synthetic Web Audio stream, so no microphone is
required and it works headless. Adds the browser flags needed for this.
alpersamur3
force-pushed
the
feat/call-answering-audio
branch
from
July 12, 2026 19:06
6e791dd to
63ec90e
Compare
Author
|
@aliyss @lindionez Hi! Could you please take a look at this PR when you have a moment? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds first-class call support: answer incoming calls, place outgoing calls, and
inject audio (e.g. a text-to-speech file) into an active call. Also fixes call
handling that no longer works on current WhatsApp Web.
New
Callmethods:accept()— answer the call (audio only by default, even for incoming video calls)end()— hang up an ongoing callplayAudio(media)— play aMessageMedia/base64 audio clip into the call so theother party hears it; resolves when playback finishes, so clips can be chained
isConnected()— whether the other party has answeredNew
Clientmethods:call(chatId, { video, waitForAnswer, answerTimeout })— place an outgoingvoice/video call; with
waitForAnswer: trueit resolves once the callee answersgetActiveCall()— the ongoing call (ringing/placing/connected), ornullFixes:
callevent: current WhatsApp Web surfaces calls throughWAWebCallCollection'sactiveCallattribute; the previous internal-mapsethook no longer fires, so
client.on('call')never triggered. Now listens tochange:activeCall(the map hook is kept as a fallback).Call.reject(): the previous signaling stanza no longer rejects on currentWhatsApp Web; it now goes through the voip stack's
rejectCall().Audio is captured from a synthetic Web Audio stream (WhatsApp's
getUserMediaisoverridden), so no microphone is required and it works headless. The browser
flags needed for this are added automatically.
Related Issue(s)
fixes #201746
Testing Summary
Test Details
Verified end-to-end against a real phone with live calls.
Outgoing voice call + audio + hang up:
Incoming call handling:
Confirmed: incoming voice/video calls fire the
callevent;accept,reject,end, sequentialplayAudioandgetActiveCallall work; the callee hears theinjected audio; video calls are answered audio-only; everything also works with a
headless browser and no microphone.
Note: the repo's
npm testintegration suite requires a configured live testaccount (
WWEBJS_TEST_REMOTE_IDetc.) and only covers messaging/groups, notcalls, so verification was done manually with real calls as shown above.
Environment
Type of Change
Checklist
npm test) — the integration suite needs a live test account and only covers messaging/groups; verified manually with real calls.index.d.ts) have been updated.example.js) / documentation have been updated.