@wppconnect/wa-js - v4.8.4-rc.0
    Preparing search index...

    Interface CallEventTypes

    interface CallEventTypes {
        "call.accepted": CallEventData;
        "call.audio_frame": {
            format: "float32" | "int16-base64";
            id?: string;
            sampleRate: number;
            samples: string | Float32Array<ArrayBufferLike>;
            source: "remote" | "local";
            timestamp: number;
        };
        "call.ended": CallEventData & {
            activeDuration?: number;
            duration?: number;
            endedByMe?: boolean;
            result?: number;
            resultName?: string;
            wasConnected: boolean;
        };
        "call.incoming_call": {
            groupJid?: any;
            id: string;
            isGroup: boolean;
            isVideo: boolean;
            offerTime: number;
            peerJid: any;
            sender: any;
        };
        "call.mute_state": {
            id: string;
            participants: { isMuted: boolean; isSelf: boolean; jid: any }[];
            peerMuted?: boolean;
            selfMuted?: boolean;
        };
        "call.outgoing_call": CallEventData;
        "call.ringing": CallEventData;
        "call.signaling": {
            attrs: { [key: string]: any };
            direction: "incoming" | "outgoing";
            id?: string;
            node: any;
            peerJid?: string;
            type: string;
        };
        "call.state_changed": CallEventData & {
            previousState?: number;
            state: number;
            stateName: string;
        };
        "call.video_state": {
            id: string;
            isSelf: boolean;
            jid?: any;
            state: number;
            stateName?: string;
        };
    }
    Index
    "call.accepted": CallEventData

    Triggered when the call is answered and connects

    WPP.on('call.accepted', async (call) => {
    await WPP.call.playAudio('https://example.com/welcome.mp3');
    });
    "call.audio_frame": {
        format: "float32" | "int16-base64";
        id?: string;
        sampleRate: number;
        samples: string | Float32Array<ArrayBufferLike>;
        source: "remote" | "local";
        timestamp: number;
    }

    Triggered for each audio frame of the active call, after WPP.call.enableAudioCapture(). Frames are 16 kHz mono, 60 ms long (960 samples).

    Type Declaration

    • format: "float32" | "int16-base64"
    • Optionalid?: string

      The active call id, when there is one

    • sampleRate: number
    • samples: string | Float32Array<ArrayBufferLike>

      Float32Array for float32, base64 of little-endian Int16 PCM for int16-base64

    • source: "remote" | "local"

      remote: what you hear; local: what you send

    • timestamp: number

      performance.now() when the frame was captured

    WPP.call.enableAudioCapture({ format: 'int16-base64' });
    WPP.on('call.audio_frame', (frame) => {
    if (frame.source === 'remote') {
    // send frame.samples to a speech-to-text service
    }
    });
    "call.ended": CallEventData & {
        activeDuration?: number;
        duration?: number;
        endedByMe?: boolean;
        result?: number;
        resultName?: string;
        wasConnected: boolean;
    }

    Triggered when the call ends, for any reason

    Type Declaration

    • OptionalactiveDuration?: number

      Duration while connected, in milliseconds

    • Optionalduration?: number

      Duration since the call started, in milliseconds

    • OptionalendedByMe?: boolean

      You ended the call

    • Optionalresult?: number

      WAWebVoipWaCallEnums.CallLogResult value

    • OptionalresultName?: string

      canceled, missed, unavailable, rejected, connected, accepted_elsewhere, failed or connected_lonely

    • wasConnected: boolean

      The call connected before ending

    WPP.on('call.ended', (call) => {
    console.log(call.id, call.resultName, call.activeDuration);
    });
    "call.incoming_call": {
        groupJid?: any;
        id: string;
        isGroup: boolean;
        isVideo: boolean;
        offerTime: number;
        peerJid: any;
        sender: any;
    }

    Triggered when you a incoming call

    Type Declaration

    • OptionalgroupJid?: any

      Group identifier supplied by WhatsApp for an incoming group call. Undefined for individual calls or when WhatsApp does not supply it.

    • id: string

      The call id

    • isGroup: boolean

      Is a call from a group

    • isVideo: boolean

      Is call with video

    • offerTime: number

      timestamp of offer

    • peerJid: any

      Wid of sender with device id

    • sender: any

      Wid of sender without device id

    WPP.on('call.incoming_call', (call) => {
    // Your code
    //Example: Reject any incoming call
    WPP.call.rejectCall(call.id);
    });
    "call.mute_state": {
        id: string;
        participants: { isMuted: boolean; isSelf: boolean; jid: any }[];
        peerMuted?: boolean;
        selfMuted?: boolean;
    }

    Triggered when you or another participant mutes or unmutes the microphone

    Type Declaration

    • id: string
    • participants: { isMuted: boolean; isSelf: boolean; jid: any }[]
    • OptionalpeerMuted?: boolean

      Mute state of the other party, for 1:1 calls

    • OptionalselfMuted?: boolean
    "call.outgoing_call": CallEventData

    Triggered when you start a call (by WPP.call.offer or any other way)

    WPP.on('call.outgoing_call', (call) => {
    console.log('Calling', call.peerJid);
    });
    "call.ringing": CallEventData

    Triggered when the other party's device starts ringing (outgoing calls)

    "call.signaling": {
        attrs: { [key: string]: any };
        direction: "incoming" | "outgoing";
        id?: string;
        node: any;
        peerJid?: string;
        type: string;
    }

    Triggered for every call signaling stanza received or sent (offer, preaccept, accept, transport, relaylatency, mute_v2, terminate, reject, ...). Only emitted while there is a listener.

    Type Declaration

    • attrs: { [key: string]: any }
    • direction: "incoming" | "outgoing"
    • Optionalid?: string

      The call id, from the call-id attribute

    • node: any

      The raw WapNode

    • OptionalpeerJid?: string
    • type: string

      The stanza tag: offer, accept, terminate, ...

    WPP.on('call.signaling', (msg) => {
    console.log(msg.direction, msg.type, msg.attrs);
    });
    "call.state_changed": CallEventData & {
        previousState?: number;
        state: number;
        stateName: string;
    }

    Triggered on every state change of the active call, incoming or outgoing.

    state is a WAWebVoipWaCallEnums.CallState value; stateName is its name (Calling, PreacceptReceived, ReceivedCall, AcceptSent, AcceptReceived, CallActive, CallStateEnding, ...)

    WPP.on('call.state_changed', (call) => {
    console.log(call.id, call.stateName);
    });
    "call.video_state": {
        id: string;
        isSelf: boolean;
        jid?: any;
        state: number;
        stateName?: string;
    }

    Triggered when you or another participant turns the camera on or off, or requests to upgrade the call to video

    Type Declaration

    • id: string
    • isSelf: boolean
    • Optionaljid?: any
    • state: number

      WAWebVoipWaCallEnums.VideoState value

    • OptionalstateName?: string