Skip to content

feat: expose call outcome on call_log messages - #201888

Open
alpersamur3 wants to merge 1 commit into
wwebjs:mainfrom
alpersamur3:feat/call-log-outcome
Open

alpersamur3 wants to merge 1 commit into
wwebjs:mainfrom
alpersamur3:feat/call-log-outcome

Conversation

@alpersamur3

Copy link
Copy Markdown

What

Exposes the outcome of call_log messages on the Message structure: message.callOutcome, message.callDuration and message.isVideoCall.

Why

There was no way to tell how a call ended. In particular, when an incoming call is answered on one of the account's other linked devices, callOutcome is 'AcceptedElsewhere', which lets a bot know it should not auto-answer. Other common values include 'Completed', 'Missed', 'Rejected', 'Cancelled' and 'Failed'.

Requested in the call PR discussion (#201825).

How

call_log messages already carry the outcome in their serialized model; this just surfaces it (along with the duration and the video flag) on the Message structure. call_log messages are delivered through the existing message / message_create events, so no new event is needed.

Usage

client.on('message', (msg) => {
    if (msg.type === 'call_log' && msg.callOutcome === 'AcceptedElsewhere') {
        // The call was answered on another linked device
    }
});

Tested

  • Verified against a live session: an incoming call answered on another device produced a call_log message with callOutcome: 'AcceptedElsewhere'; a normal completed call read 'Completed'.
  • Unit tests added in tests/callLog.js.

@alpersamur3

Copy link
Copy Markdown
Author

Re-checked against the current WA Web (2.3000.1048354754): call_log messages still carry callOutcome, callDuration and isVideoCall, so this is still good to go.

@BenyFilho @tuyuribr @aliyss this one is small and independent of the other call PRs, if you have a moment to review it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications tests Test related typings Type definitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant