Interface ChatEventTypes

interface ChatEventTypes {
    chat.active_chat: null | ChatModel;
    chat.live_location_end: {
        chat: Wid;
        id: Wid;
        seq: number;
    };
    chat.live_location_start: {
        accuracy?: number;
        chat: Wid;
        degrees?: number;
        id: Wid;
        lat: number;
        lng: number;
        msgId: MsgKey;
        shareDuration: number;
        speed?: number;
    };
    chat.live_location_update: {
        accuracy?: number;
        comment: string;
        degrees?: number;
        elapsed: number;
        id: Wid;
        lastUpdated: number;
        lat: number;
        lng: number;
        speed?: number;
    };
    chat.msg_ack_change: {
        ack: number;
        chat: Wid;
        ids: MsgKey[];
        sender?: Wid;
    };
    chat.msg_edited: {
        chat: Wid;
        id: string;
        msg: MsgModel;
    };
    chat.msg_revoke: {
        author?: Wid;
        from: Wid;
        id: MsgKey;
        refId: MsgKey;
        to: Wid;
        type: "revoke" | "sender_revoke" | "admin_revoke";
    };
    chat.new_message: MsgModel;
    chat.new_reaction: {
        id: MsgKey;
        msgId: MsgKey;
        orphan: number;
        orphanReason: any;
        reactionText: string;
        read: boolean;
        sender: Wid;
        timestamp: number;
    };
    chat.poll_response: {
        chatId: Wid;
        msgId: MsgKey;
        selectedOptions: number[];
        sender: Wid;
        timestamp: number;
    };
    chat.presence_change: {
        id: Wid;
        isContact?: boolean;
        isGroup: boolean;
        isOnline: boolean;
        isUser: boolean;
        participants?: {
            id: string;
            shortName: string;
            state: string;
        }[];
        shortName: string;
        state: string;
        t: number;
    };
    chat.update_label: {
        chat: ChatModel;
        ids: string[];
        labels: Label[];
        type: "add" | "remove";
    };
}

Properties

chat.active_chat: null | ChatModel

Triggered when change the active chat

WPP.on('chat.active_chat', (chat) => {
// Your code
});
chat.live_location_end: {
    chat: Wid;
    id: Wid;
    seq: number;
}

Temporary unsuported by WhatsApp Web Multi-Device

chat.live_location_start: {
    accuracy?: number;
    chat: Wid;
    degrees?: number;
    id: Wid;
    lat: number;
    lng: number;
    msgId: MsgKey;
    shareDuration: number;
    speed?: number;
}
chat.live_location_update: {
    accuracy?: number;
    comment: string;
    degrees?: number;
    elapsed: number;
    id: Wid;
    lastUpdated: number;
    lat: number;
    lng: number;
    speed?: number;
}

Temporary unsuported by WhatsApp Web Multi-Device

chat.msg_ack_change: {
    ack: number;
    chat: Wid;
    ids: MsgKey[];
    sender?: Wid;
}

Type declaration

  • ack: number
  • chat: Wid

    The chat that sended the messeage

  • ids: MsgKey[]

    Message id of revoke event

  • Optionalsender?: Wid

    Who sended the ack, only for groups, broadcast and status

chat.msg_edited: {
    chat: Wid;
    id: string;
    msg: MsgModel;
}

On Message edit

chat.msg_revoke: {
    author?: Wid;
    from: Wid;
    id: MsgKey;
    refId: MsgKey;
    to: Wid;
    type: "revoke" | "sender_revoke" | "admin_revoke";
}

Type declaration

  • Optionalauthor?: Wid

    Author of message, only for groups

  • from: Wid
  • id: MsgKey

    Message id of revoke event

  • refId: MsgKey

    Message id of revoked message

  • to: Wid
  • type: "revoke" | "sender_revoke" | "admin_revoke"

    Type of revoke

chat.new_message: MsgModel

Triggered when new message is received

WPP.on('chat.new_message', (msg) => {
// Your code
});
chat.new_reaction: {
    id: MsgKey;
    msgId: MsgKey;
    orphan: number;
    orphanReason: any;
    reactionText: string;
    read: boolean;
    sender: Wid;
    timestamp: number;
}

Triggered when a new reaction is received

Type declaration

  • id: MsgKey

    Reaction ID

  • msgId: MsgKey

    Message ID that received the reaction

  • orphan: number
  • orphanReason: any
  • reactionText: string

    The reaction emoji or empty if removed

  • read: boolean
  • sender: Wid
  • timestamp: number
WPP.on('chat.new_reaction', (msg) => {
// Your code
});
chat.poll_response: {
    chatId: Wid;
    msgId: MsgKey;
    selectedOptions: number[];
    sender: Wid;
    timestamp: number;
}

On Poll response

chat.presence_change: {
    id: Wid;
    isContact?: boolean;
    isGroup: boolean;
    isOnline: boolean;
    isUser: boolean;
    participants?: {
        id: string;
        shortName: string;
        state: string;
    }[];
    shortName: string;
    state: string;
    t: number;
}

On presence change

chat.update_label: {
    chat: ChatModel;
    ids: string[];
    labels: Label[];
    type: "add" | "remove";
}

On Labels update