-
-
-
-
-
-
-
- Properties
-
-
- Current connection information
-
-
- pupBrowser
- puppeteer.Browser
-
-
- pupPage
- puppeteer.Page
-
-
-
- Methods
-
- async
- _muteUnmuteChat (chatId, action, unmuteDateTs) → Promise containing {isMuted: boolean, muteExpiration: number}
- Internal method to mute or unmute the chat
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
- ID of the chat that will be muted/unmuted
-
-
-
-
- action
-
-
- string
-
-
-
-
-
- The action: 'MUTE' or 'UNMUTE'
-
-
-
-
- unmuteDateTs
-
-
- number
-
-
-
-
-
- Timestamp at which the chat will be unmuted
-
-
-
-
-
-
- Returns
-
- Promise containing {isMuted: boolean, muteExpiration: number}
-
-
- async
- acceptGroupV4Invite (inviteInfo) → Promise containing Object
- Accepts a private invitation to join a group
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- inviteInfo
-
-
- object
-
-
-
-
-
- Invite V4 Info
-
-
-
-
-
-
- Returns
-
- Promise containing Object
-
-
- async
- acceptInvite (inviteCode) → Promise containing string
- Accepts an invitation to join a group
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- inviteCode
-
-
- string
-
-
-
-
-
- Invitation code
-
-
-
-
-
-
- Returns
-
- Promise containing string
-
Id of the joined Chat
-
-
-
- async
- addOrRemoveLabels (labelIds, chatIds) → Promise containing void
- Change labels in chats
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- labelIds
-
-
- Array of (number or string)
-
-
-
-
-
-
-
-
-
- chatIds
-
-
- Array of string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing void
-
-
- async
- approveGroupMembershipRequests (groupId, options) → Promise containing Array of MembershipRequestActionResult
- Approves membership requests if any
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- groupId
-
-
- string
-
-
-
-
-
- The group ID to get the membership request for
-
-
-
-
- options
-
-
- MembershipRequestActionOptions
-
-
-
-
-
- Options for performing a membership request action
-
-
-
-
-
-
- Returns
-
- Promise containing Array of MembershipRequestActionResult
-
Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
-
-
-
- async
- archiveChat () → boolean
- Enables and returns the archive state of the Chat
-
- Returns
-
- boolean
-
-
- async
- attachEventListeners ()
- Attach event listeners to WA Web
- Private function
-
- Property
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- reinject
-
-
- boolean
-
-
-
-
-
- is this a reinject?
-
-
-
-
-
-
-
- async
- createGroup (title, participants, options) → Promise containing (CreateGroupResult or string)
- Creates a new group
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- title
-
-
- string
-
-
-
-
-
- Group title
-
-
-
-
- participants
-
-
- (string, Contact , Array of (Contact or string), or undefined)
-
-
-
-
-
- A single Contact object or an ID as a string or an array of Contact objects or contact IDs to add to the group
-
-
-
-
- options
-
-
- CreateGroupOptions
-
-
-
-
-
- An object that handles options for group creation
-
-
-
-
-
-
- Returns
-
- Promise containing (CreateGroupResult or string)
-
Object with resulting data or an error message as a string
-
-
-
- async
-
- Deletes the contact from user's addressbook
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- phoneNumber
-
-
- string
-
-
-
-
-
- The contact's phone number in a format "17182222222", where "1" is a country code
-
-
-
-
-
-
- Returns
-
- Promise containing void
-
-
- async
- deleteProfilePicture () → Promise containing boolean
- Deletes the current user's profile picture.
-
- Returns
-
- Promise containing boolean
-
Returns true if the picture was properly deleted.
-
-
-
- async
- destroy ()
- Closes the client
-
-
- async
-
- Gets all blocked contacts by host account
-
- Returns
-
- Promise containing Array of Contact
-
-
- async
- getBroadcasts () → Promise containing Array of Broadcast
- Get all current Broadcast
-
- Returns
-
- Promise containing Array of Broadcast
-
-
- async
- getChatById (chatId) → Promise containing Chat
- Get chat instance by ID
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Chat
-
-
- async
- getChatLabels (chatId) → Promise containing Array of Label
- Get all Labels assigned to a chat
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Array of Label
-
-
- async
- getChats () → Promise containing Array of Chat
- Get all current chat instances
-
- Returns
-
- Promise containing Array of Chat
-
-
- async
- getChatsByLabelId (labelId) → Promise containing Array of Chat
- Get all Chats for a specific Label
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- labelId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Array of Chat
-
-
- async
- getCommonGroups (contactId) → Promise containing Array of WAWebJS.ChatId
- Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- contactId
-
-
- string
-
-
-
-
-
- the whatsapp user's ID (_serialized format)
-
-
-
-
-
-
- Returns
-
- Promise containing Array of WAWebJS.ChatId
-
-
- async
-
- Get contact instance by ID
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- contactId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Contact
-
-
- async
-
- Get user device count by ID
- Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
- So for a non-enterprise user with one WaWeb connection it should return "2"
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- userId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing number
-
-
- async
-
- Get all current contact instances
-
- Returns
-
- Promise containing Array of Contact
-
-
- async
- getCountryCode (number) → Promise containing string
- Get the country code of a WhatsApp ID.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- number
-
-
- string
-
-
-
-
-
- Number or ID
-
-
-
-
-
-
- Returns
-
- Promise containing string
-
-
- async
-
- Get the formatted number of a WhatsApp ID.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- number
-
-
- string
-
-
-
-
-
- Number or ID
-
-
-
-
-
-
- Returns
-
- Promise containing string
-
-
- async
- getGroupMembershipRequests (groupId) → Promise containing Array of GroupMembershipRequest
- Gets an array of membership requests
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- groupId
-
-
- string
-
-
-
-
-
- The ID of a group to get membership requests for
-
-
-
-
-
-
- Returns
-
- Promise containing Array of GroupMembershipRequest
-
An array of membership requests
-
-
-
- async
- getInviteInfo (inviteCode) → Promise containing object
- Returns an object with information about the invite code's group
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- inviteCode
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing object
-
Invite information
-
-
-
- async
- getLabelById (labelId) → Promise containing Label
- Get Label instance by ID
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- labelId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Label
-
-
- async
- getLabels () → Promise containing Array of Label
- Get all current Labels
-
- Returns
-
- Promise containing Array of Label
-
-
- async
- getNumberId (number) → Promise containing (Object or null)
- Get the registered WhatsApp ID for a number.
- Will return null if the number is not registered on WhatsApp.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- number
-
-
- string
-
-
-
-
-
- Number or ID ("@c.us" will be automatically appended if not specified)
-
-
-
-
-
-
- Returns
-
- Promise containing (Object or null)
-
-
- async
- getProfilePicUrl (contactId) → Promise containing string
- Returns the contact ID's profile picture URL, if privacy settings allow it
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- contactId
-
-
- string
-
-
-
-
-
- the whatsapp user's ID
-
-
-
-
-
-
- Returns
-
- Promise containing string
-
-
- async
-
- Gets the current connection state for the client
-
- Returns
-
- WAState
-
-
- async
- getWWebVersion () → Promise containing string
- Returns the version of WhatsApp Web currently being run
-
- Returns
-
- Promise containing string
-
-
- async
- initialize ()
- Sets up events and requirements, kicks off authentication request
-
-
- async
- inject ()
- Injection logic
- Private function
-
-
- async
- isRegisteredUser (id) → Promise containing Boolean
- Check if a given ID is registered in whatsapp
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- id
-
-
- string
-
-
-
-
-
- the whatsapp user's ID
-
-
-
-
-
-
- Returns
-
- Promise containing Boolean
-
-
- async
- logout ()
- Logs out the client, closing the current session
-
-
- async
- markChatUnread (chatId)
- Mark the Chat as unread
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
- ID of the chat that will be marked as unread
-
-
-
-
-
-
-
- async
- muteChat (chatId, unmuteDate) → Promise containing {isMuted: boolean, muteExpiration: number}
- Mutes this chat forever, unless a date is specified
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
- ID of the chat that will be muted
-
-
-
-
- unmuteDate
-
-
- Date
-
-
-
-
-
- Date when the chat will be unmuted, don't provide a value to mute forever
- Value can be null.
-
-
-
-
-
-
- Returns
-
- Promise containing {isMuted: boolean, muteExpiration: number}
-
-
- async
- pinChat () → Promise containing boolean
- Pins the Chat
-
- Returns
-
- Promise containing boolean
-
New pin state. Could be false if the max number of pinned chats was reached.
-
-
-
- async
- rejectGroupMembershipRequests (groupId, options) → Promise containing Array of MembershipRequestActionResult
- Rejects membership requests if any
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- groupId
-
-
- string
-
-
-
-
-
- The group ID to get the membership request for
-
-
-
-
- options
-
-
- MembershipRequestActionOptions
-
-
-
-
-
- Options for performing a membership request action
-
-
-
-
-
-
- Returns
-
- Promise containing Array of MembershipRequestActionResult
-
Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
-
-
-
- async
- requestPairingCode (phoneNumber, showNotification) → Promise containing string
- Request authentication via pairing code instead of QR code
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- phoneNumber
-
-
- string
-
-
-
-
-
- Phone number in international, symbol-free format (e.g. 12025550108 for US, 551155501234 for Brazil)
-
-
-
-
- showNotification
-
-
- boolean
-
-
-
-
-
- Show notification to pair on phone number
- Defaults to true.
-
-
-
-
-
-
- Returns
-
- Promise containing string
-
-
- Returns a pairing code in format "ABCDEFGH"
-
-
-
- async
- resetState ()
- Force reset of connection state for the client
-
-
- async
-
- Save new contact to user's addressbook or edit the existing one
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- phoneNumber
-
-
- string
-
-
-
-
-
- The contact's phone number in a format "17182222222", where "1" is a country code
-
-
-
-
- firstName
-
-
- string
-
-
-
-
-
-
-
-
-
- lastName
-
-
- string
-
-
-
-
-
-
-
-
-
- syncToAddressbook
-
-
- boolean
-
-
- Yes
-
-
- If set to true, the contact will also be saved to the user's address book on their phone. False by default
- Defaults to false.
-
-
-
-
-
-
- Returns
-
-
- async
- searchMessages (query[, options]) → Promise containing Array of Message
- Searches for messages
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- query
-
-
- string
-
-
-
-
-
-
-
-
-
- options
-
-
- Object
-
-
- Yes
-
-
- Values in options have the following properties:
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- page
-
-
- number
-
-
- Yes
-
-
-
-
-
-
- limit
-
-
- number
-
-
- Yes
-
-
-
-
-
-
- chatId
-
-
- string
-
-
- Yes
-
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing Array of Message
-
-
- async
- sendMessage (chatId, content[, options]) → Promise containing Message
- Send a message to a specific chatId
-
-
- Returns
-
- Promise containing Message
-
Message that was just sent
-
-
-
- async
- sendPresenceAvailable ()
- Marks the client as online
-
-
- async
- sendPresenceUnavailable ()
- Marks the client as unavailable
-
-
- async
- sendSeen (chatId) → Promise containing boolean
- Mark as seen for the Chat
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing boolean
-
result
-
-
-
- async
- setAutoDownloadAudio (flag)
- Setting autoload download audio
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- flag
-
-
- boolean
-
-
-
-
-
- true/false
-
-
-
-
-
-
-
- async
- setAutoDownloadDocuments (flag)
- Setting autoload download documents
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- flag
-
-
- boolean
-
-
-
-
-
- true/false
-
-
-
-
-
-
-
- async
- setAutoDownloadPhotos (flag)
- Setting autoload download photos
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- flag
-
-
- boolean
-
-
-
-
-
- true/false
-
-
-
-
-
-
-
- async
- setAutoDownloadVideos (flag)
- Setting autoload download videos
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- flag
-
-
- boolean
-
-
-
-
-
- true/false
-
-
-
-
-
-
-
- async
- setBackgroundSync (flag) → Promise containing boolean
- Setting background synchronization.
- NOTE: this action will take effect after you restart the client.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- flag
-
-
- boolean
-
-
-
-
-
- true/false
-
-
-
-
-
-
- Returns
-
- Promise containing boolean
-
-
- async
- setDisplayName (displayName) → Promise containing Boolean
- Sets the current user's display name.
- This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- displayName
-
-
- string
-
-
-
-
-
- New display name
-
-
-
-
-
-
- Returns
-
- Promise containing Boolean
-
-
- async
- setProfilePicture (media) → Promise containing boolean
- Sets the current user's profile picture.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- media
-
-
- MessageMedia
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing boolean
-
Returns true if the picture was properly updated.
-
-
-
- async
- setStatus (status)
- Sets the current user's status message
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- status
-
-
- string
-
-
-
-
-
- New status message
-
-
-
-
-
-
-
- async
- syncHistory (chatId) → Promise containing boolean
- Sync chat history conversation
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
- Returns
-
- Promise containing boolean
-
True if operation completed successfully, false otherwise.
-
-
-
- async
- unarchiveChat () → boolean
- Changes and returns the archive state of the Chat
-
- Returns
-
- boolean
-
-
- async
- unmuteChat (chatId) → Promise containing {isMuted: boolean, muteExpiration: number}
- Unmutes the Chat
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
- ID of the chat that will be unmuted
-
-
-
-
-
-
- Returns
-
- Promise containing {isMuted: boolean, muteExpiration: number}
-
-
- async
- unpinChat () → Promise containing boolean
- Unpins the Chat
-
- Returns
-
- Promise containing boolean
-
New pin state
-
-
-
-
- Events
-
- auth_failure
- Emitted when there has been an error while trying to restore an existing session
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
-
- authenticated
- Emitted when authentication is successful
-
-
- change_battery
- Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- batteryInfo
-
-
- object
-
-
-
-
-
- Values in batteryInfo have the following properties:
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- battery
-
-
- number
-
-
-
-
-
- The current battery percentage
-
-
-
-
- plugged
-
-
- boolean
-
-
-
-
-
- Indicates if the phone is plugged in (true) or not (false)
-
-
-
-
-
-
-
-
-
-
- Deprecated
-
-
- change_state
- Emitted when the connection state changes
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- state
-
-
- WAState
-
-
-
-
-
- the new connection state
-
-
-
-
-
-
-
- chat_archived
- Emitted when a chat is archived/unarchived
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chat
-
-
- Chat
-
-
-
-
-
-
-
-
-
- currState
-
-
- boolean
-
-
-
-
-
-
-
-
-
- prevState
-
-
- boolean
-
-
-
-
-
-
-
-
-
-
-
-
- chat_removed
- Emitted when a chat is removed
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chat
-
-
- Chat
-
-
-
-
-
-
-
-
-
-
-
-
-
- Emitted when a contact or a group participant changes their phone number.
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- Message with more information about the event.
-
-
-
-
- oldId
-
-
- String
-
-
-
-
-
- The user's id (an old one) who changed their phone number
- and who triggered the notification.
-
-
-
-
- newId
-
-
- String
-
-
-
-
-
- The user's new id after the change.
-
-
-
-
- isContact
-
-
- Boolean
-
-
-
-
-
- Indicates if a contact or a group participant changed their phone number.
-
-
-
-
-
-
-
- disconnected
- Emitted when the client has been disconnected
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- reason
-
-
- (WAState or "LOGOUT")
-
-
-
-
-
- reason that caused the disconnect
-
-
-
-
-
-
-
- group_admin_changed
- Emitted when a current user is promoted to an admin or demoted to a regular user.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- notification
-
-
- GroupNotification
-
-
-
-
-
- GroupNotification with more information about the action
-
-
-
-
-
-
-
- group_join
- Emitted when a user joins the chat via invite link or is added by an admin.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- notification
-
-
- GroupNotification
-
-
-
-
-
- GroupNotification with more information about the action
-
-
-
-
-
-
-
- group_leave
- Emitted when a user leaves the chat or is removed by an admin.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- notification
-
-
- GroupNotification
-
-
-
-
-
- GroupNotification with more information about the action
-
-
-
-
-
-
-
- group_membership_request
- Emitted when some user requested to join the group
- that has the membership approval mode turned on
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- notification
-
-
- GroupNotification
-
-
-
-
-
- GroupNotification with more information about the action
- Values in notification have the following properties:
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- chatId
-
-
- string
-
-
-
-
-
- The group ID the request was made for
-
-
-
-
- author
-
-
- string
-
-
-
-
-
- The user ID that made a request
-
-
-
-
- timestamp
-
-
- number
-
-
-
-
-
- The timestamp the request was made at
-
-
-
-
-
-
-
-
-
-
-
- group_update
- Emitted when group settings are updated, such as subject, description or picture.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- notification
-
-
- GroupNotification
-
-
-
-
-
- GroupNotification with more information about the action
-
-
-
-
-
-
-
- incoming_call
- Emitted when a call is received
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- call
-
-
- object
-
-
-
-
-
- Values in call have the following properties:
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- id
-
-
- number
-
-
-
-
-
- Call id
-
-
-
-
- peerJid
-
-
- string
-
-
-
-
-
- Who called
-
-
-
-
- isVideo
-
-
- boolean
-
-
-
-
-
- if is video
-
-
-
-
- isGroup
-
-
- boolean
-
-
-
-
-
- if is group
-
-
-
-
- canHandleLocally
-
-
- boolean
-
-
-
-
-
- if we can handle in waweb
-
-
-
-
- outgoing
-
-
- boolean
-
-
-
-
-
- if is outgoing
-
-
-
-
- webClientShouldHandle
-
-
- boolean
-
-
-
-
-
- If Waweb should handle
-
-
-
-
- participants
-
-
- object
-
-
-
-
-
- Participants
-
-
-
-
-
-
-
-
-
-
-
-
- Emitted when media has been uploaded for a message sent by the client.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message with media that was uploaded
-
-
-
-
-
-
-
- message
- Emitted when a new message is received.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message that was received
-
-
-
-
-
-
-
- message_ack
- Emitted when an ack event occurrs on message type.
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message that was affected
-
-
-
-
- ack
-
-
- MessageAck
-
-
-
-
-
- The new ACK value
-
-
-
-
-
-
-
- message_ciphertext
- Emitted when messages are edited
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
-
-
-
-
-
-
-
- message_create
- Emitted when a new message is created, which may include the current user's own messages.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message that was created
-
-
-
-
-
-
-
- message_edit
- Emitted when messages are edited
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
-
-
-
-
- newBody
-
-
- string
-
-
-
-
-
-
-
-
-
- prevBody
-
-
- string
-
-
-
-
-
-
-
-
-
-
-
-
- message_reaction
- Emitted when a reaction is sent, received, updated or removed
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- reaction
-
-
- object
-
-
-
-
-
- Values in reaction have the following properties:
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- id
-
-
- object
-
-
-
-
-
- Reaction id
-
-
-
-
- orphan
-
-
- number
-
-
-
-
-
- Orphan
-
-
-
-
- orphanReason
-
-
- string
-
-
-
-
-
- Orphan reason
- Value can be null.
-
-
-
-
- timestamp
-
-
- number
-
-
-
-
-
- Timestamp
-
-
-
-
- reaction
-
-
- string
-
-
-
-
-
- Reaction
-
-
-
-
- read
-
-
- boolean
-
-
-
-
-
- Read
-
-
-
-
- msgId
-
-
- object
-
-
-
-
-
- Parent message id
-
-
-
-
- senderId
-
-
- string
-
-
-
-
-
- Sender id
-
-
-
-
- ack
-
-
- number
-
-
-
-
-
- Ack
- Value can be null.
-
-
-
-
-
-
-
-
-
-
-
- message_revoke_everyone
- Emitted when a message is deleted for everyone in the chat.
-
- Parameters
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message that was revoked, in its current state. It will not contain the original message's data.
-
-
-
-
- revoked_msg
-
-
- Message
-
-
-
-
-
- The message that was revoked, before it was revoked. It will contain the message's original data.
- Note that due to the way this data is captured, it may be possible that this param will be undefined.
- Value can be null.
-
-
-
-
-
-
-
- message_revoke_me
- Emitted when a message is deleted by the current user.
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- message
-
-
- Message
-
-
-
-
-
- The message that was revoked
-
-
-
-
-
-
-
- qr
- Emitted when a QR code is received
-
- Parameter
-
-
-
- Name
- Type
- Optional
- Description
-
-
-
-
-
- qr
-
-
- string
-
-
-
-
-
- QR Code
-
-
-
-
-
-
-
- ready
- Emitted when the client has initialized and is ready to receive messages.
-
-
- vote_update
- Emitted when some poll option is selected or deselected,
- shows a user's current selected option(s) on the poll
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Methods
+
+
+
+
+
+
+
+ saveOrEditAddressbookContact(phoneNumber, firstName, lastName[, syncToAddressbook])
+
+
+ searchChannels(searchOptions)
+
+
+ searchMessages(query[, options])
+
+
+ sendChannelAdminInvite(chatId, channelId, options)
+
+
+ sendMessage(chatId, content[, options])
+
+
+ sendPresenceAvailable()
+
+
+ sendPresenceUnavailable()
+
+
+ sendSeen(chatId)
+
+
+ setAutoDownloadAudio(flag)
+
+
+ setAutoDownloadDocuments(flag)
+
+
+ setAutoDownloadPhotos(flag)
+
+
+ setAutoDownloadVideos(flag)
+
+
+ setBackgroundSync(flag)
+
+
+ setDisplayName(displayName)
+
+
+ setProfilePicture(media)
+
+
+ setStatus(status)
+
+
+ subscribeToChannel(channelId)
+
+
+ syncHistory(chatId)
+
+
+ transferChannelOwnership(channelId, newOwnerId, options)
+
+
+ unarchiveChat()
+
+
+ unmuteChat(chatId)
+
+
+ unpinChat()
+
+
+ unsubscribeFromChannel(channelId, options)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+
+ Current connection information
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pupBrowser
+ puppeteer.Browser
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pupPage
+ puppeteer.Page
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Methods
+
+ async
_muteUnmuteChat (chatId, action, unmuteDateTs) → Promise containing {isMuted: boolean, muteExpiration: number} Internal method to mute or unmute the chat
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ ID of the chat that will be muted/unmuted
+
+
+
+
+
+ action
+
+
+ string
+
+
+
+
+
+ The action: 'MUTE' or 'UNMUTE'
+
+
+
+
+
+ unmuteDateTs
+
+
+ number
+
+
+
+
+
+ Timestamp at which the chat will be unmuted
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing {isMuted: boolean, muteExpiration: number}
+
+
+
+
+
+ async
acceptChannelAdminInvite (channelId) → Promise containing boolean Accepts a channel admin invitation and promotes the current user to a channel admin
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The channel ID to accept the admin invitation from
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
acceptGroupV4Invite (inviteInfo) → Promise containing Object Accepts a private invitation to join a group
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ inviteInfo
+
+
+ object
+
+
+
+
+
+ Invite V4 Info
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Object
+
+
+
+
+
+ async
acceptInvite (inviteCode) → Promise containing string Accepts an invitation to join a group
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ inviteCode
+
+
+ string
+
+
+
+
+
+ Invitation code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
Id of the joined Chat
+
+
+
+
+
+ async
addOrRemoveLabels (labelIds, chatIds) → Promise containing void Change labels in chats
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ labelIds
+
+
+ Array of (number or string)
+
+
+
+
+
+
+
+
+
+
+ chatIds
+
+
+ Array of string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing void
+
+
+
+
+
+ async
approveGroupMembershipRequests (groupId, options) → Promise containing Array of MembershipRequestActionResult Approves membership requests if any
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ groupId
+
+
+ string
+
+
+
+
+
+ The group ID to get the membership request for
+
+
+
+
+
+ options
+
+
+ MembershipRequestActionOptions
+
+
+
+
+
+ Options for performing a membership request action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of MembershipRequestActionResult
Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
+
+
+
+
+
+ async
archiveChat () → boolean Enables and returns the archive state of the Chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ boolean
+
+
+
+
+
+ async
attachEventListeners () Attach event listeners to WA Web
+Private function
+
+
+
+
+ Property
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ reinject
+
+
+ boolean
+
+
+
+
+
+ is this a reinject?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
createChannel (title, options) → Promise containing (CreateChannelResult or string) Creates a new channel
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ title
+
+
+ string
+
+
+
+
+
+ The channel name
+
+
+
+
+
+ options
+
+
+ CreateChannelOptions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing (CreateChannelResult or string)
Returns an object that handles the result for the channel creation or an error message as a string
+
+
+
+
+
+ async
createGroup (title, participants, options) → Promise containing (CreateGroupResult or string) Creates a new group
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ title
+
+
+ string
+
+
+
+
+
+ Group title
+
+
+
+
+
+ participants
+
+
+ (string, Contact , Array of (Contact or string), or undefined)
+
+
+
+
+
+ A single Contact object or an ID as a string or an array of Contact objects or contact IDs to add to the group
+
+
+
+
+
+ options
+
+
+ CreateGroupOptions
+
+
+
+
+
+ An object that handles options for group creation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing (CreateGroupResult or string)
Object with resulting data or an error message as a string
+
+
+
+
+
+ async
Deletes the contact from user's addressbook
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ phoneNumber
+
+
+ string
+
+
+
+
+
+ The contact's phone number in a format "17182222222", where "1" is a country code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing void
+
+
+
+
+
+ async
deleteChannel (channelId) → Promise containing boolean Deletes the channel you created
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The ID of a channel to delete
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
deleteProfilePicture () → Promise containing boolean Deletes the current user's profile picture.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the picture was properly deleted.
+
+
+
+
+
+ async
demoteChannelAdmin (channelId, userId) → Promise containing boolean Demotes a channel admin to a regular subscriber (can be used also for self-demotion)
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The channel ID to demote an admin in
+
+
+
+
+
+ userId
+
+
+ string
+
+
+
+
+
+ The user ID to demote
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
destroy () Closes the client
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
Gets all blocked contacts by host account
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Contact
+
+
+
+
+
+ async
getBroadcasts () → Promise containing Array of Broadcast Get all current Broadcast
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Broadcast
+
+
+
+
+
+ async
getChannelByInviteCode (inviteCode) → Promise containing Channel Gets a Channel instance by invite code
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ inviteCode
+
+
+ string
+
+
+
+
+
+ The code that comes after the 'https://whatsapp.com/channel/'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Channel
+
+
+
+
+
+ async
getChannels () → Promise containing Array of Channel Gets all cached Channel instance
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Channel
+
+
+
+
+
+ async
getChatById (chatId) → Promise containing (Chat or Channel ) Gets chat or channel instance by ID
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing (Chat or Channel )
+
+
+
+
+
+ async
getChatLabels (chatId) → Promise containing Array of Label Get all Labels assigned to a chat
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Label
+
+
+
+
+
+ async
getChats () → Promise containing Array of Chat Get all current chat instances
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Chat
+
+
+
+
+
+ async
getChatsByLabelId (labelId) → Promise containing Array of Chat Get all Chats for a specific Label
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ labelId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Chat
+
+
+
+
+
+ async
getCommonGroups (contactId) → Promise containing Array of WAWebJS.ChatId Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ contactId
+
+
+ string
+
+
+
+
+
+ the whatsapp user's ID (_serialized format)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of WAWebJS.ChatId
+
+
+
+
+
+ async
Get contact instance by ID
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ contactId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Contact
+
+
+
+
+
+ async
Get user device count by ID
+Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
+So for a non-enterprise user with one WaWeb connection it should return "2"
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ userId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing number
+
+
+
+
+
+ async
Get all current contact instances
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Contact
+
+
+
+
+
+ async
getCountryCode (number) → Promise containing string Get the country code of a WhatsApp ID.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ number
+
+
+ string
+
+
+
+
+
+ Number or ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
+
+
+
+
+
+ async
Get the formatted number of a WhatsApp ID.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ number
+
+
+ string
+
+
+
+
+
+ Number or ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
+
+
+
+
+
+ async
getGroupMembershipRequests (groupId) → Promise containing Array of GroupMembershipRequest Gets an array of membership requests
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ groupId
+
+
+ string
+
+
+
+
+
+ The ID of a group to get membership requests for
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of GroupMembershipRequest
An array of membership requests
+
+
+
+
+
+ async
getInviteInfo (inviteCode) → Promise containing object Returns an object with information about the invite code's group
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ inviteCode
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing object
Invite information
+
+
+
+
+
+ async
getLabelById (labelId) → Promise containing Label Get Label instance by ID
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ labelId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Label
+
+
+
+
+
+ async
getLabels () → Promise containing Array of Label Get all current Labels
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Label
+
+
+
+
+
+ async
getNumberId (number) → Promise containing (Object or null) Get the registered WhatsApp ID for a number.
+Will return null if the number is not registered on WhatsApp.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ number
+
+
+ string
+
+
+
+
+
+ Number or ID ("@c.us" will be automatically appended if not specified)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing (Object or null)
+
+
+
+
+
+ async
getProfilePicUrl (contactId) → Promise containing string Returns the contact ID's profile picture URL, if privacy settings allow it
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ contactId
+
+
+ string
+
+
+
+
+
+ the whatsapp user's ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
+
+
+
+
+
+ async
Gets the current connection state for the client
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ WAState
+
+
+
+
+
+ async
getWWebVersion () → Promise containing string Returns the version of WhatsApp Web currently being run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
+
+
+
+
+
+ async
initialize () Sets up events and requirements, kicks off authentication request
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
inject () Injection logic
+Private function
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
isRegisteredUser (id) → Promise containing Boolean Check if a given ID is registered in whatsapp
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ id
+
+
+ string
+
+
+
+
+
+ the whatsapp user's ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Boolean
+
+
+
+
+
+ async
logout () Logs out the client, closing the current session
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
markChatUnread (chatId) Mark the Chat as unread
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ ID of the chat that will be marked as unread
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
muteChat (chatId, unmuteDate) → Promise containing {isMuted: boolean, muteExpiration: number} Mutes this chat forever, unless a date is specified
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ ID of the chat that will be muted
+
+
+
+
+
+ unmuteDate
+
+
+ Date
+
+
+
+
+
+ Date when the chat will be unmuted, don't provide a value to mute forever
+ Value can be null.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing {isMuted: boolean, muteExpiration: number}
+
+
+
+
+
+ async
pinChat () → Promise containing boolean Pins the Chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
New pin state. Could be false if the max number of pinned chats was reached.
+
+
+
+
+
+ async
rejectGroupMembershipRequests (groupId, options) → Promise containing Array of MembershipRequestActionResult Rejects membership requests if any
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ groupId
+
+
+ string
+
+
+
+
+
+ The group ID to get the membership request for
+
+
+
+
+
+ options
+
+
+ MembershipRequestActionOptions
+
+
+
+
+
+ Options for performing a membership request action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of MembershipRequestActionResult
Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
+
+
+
+
+
+ async
requestPairingCode (phoneNumber, showNotification) → Promise containing string Request authentication via pairing code instead of QR code
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ phoneNumber
+
+
+ string
+
+
+
+
+
+ Phone number in international, symbol-free format (e.g. 12025550108 for US, 551155501234 for Brazil)
+
+
+
+
+
+ showNotification
+
+
+ boolean
+
+
+
+
+
+ Show notification to pair on phone number
+ Defaults to true.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing string
+Returns a pairing code in format "ABCDEFGH"
+
+
+
+
+
+
+ async
resetState () Force reset of connection state for the client
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
revokeChannelAdminInvite (channelId, userId) → Promise containing boolean Revokes a channel admin invitation sent to a user by a channel owner
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The channel ID an invitation belongs to
+
+
+
+
+
+ userId
+
+
+ string
+
+
+
+
+
+ The user ID the invitation was sent to
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
Save new contact to user's addressbook or edit the existing one
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ phoneNumber
+
+
+ string
+
+
+
+
+
+ The contact's phone number in a format "17182222222", where "1" is a country code
+
+
+
+
+
+ firstName
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ lastName
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ syncToAddressbook
+
+
+ boolean
+
+
+ Yes
+
+
+ If set to true, the contact will also be saved to the user's address book on their phone. False by default
+ Defaults to false.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+
+
+
+
+
+
+ async
searchChannels (searchOptions) Searches for channels based on search criteria, there are some notes:
+
+The method finds only channels you are not subscribed to currently
+If you have never been subscribed to a found channel
+or you have unsubscribed from it with UnsubscribeOptions.deleteLocalModels set to 'true',
+the lastMessage property of a found channel will be 'null'
+
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ searchOptions
+
+
+ Object
+
+
+
+
+
+ Search options
+ Values in searchOptions have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ searchText
+
+
+ string
+
+
+ Yes
+
+
+ Text to search
+ Defaults to ''.
+
+
+
+
+
+ countryCodes
+
+
+ Array of string
+
+
+ Yes
+
+
+ Array of country codes in 'ISO 3166-1 alpha-2' standart (@see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to search for channels created in these countries
+ Defaults to [your local region].
+
+
+
+
+
+ skipSubscribedNewsletters
+
+
+ boolean
+
+
+ Yes
+
+
+ If true, channels that user is subscribed to won't appear in found channels
+ Defaults to false.
+
+
+
+
+
+ view
+
+
+ number
+
+
+ Yes
+
+
+ View type, makes sense only when the searchText is empty. Valid values to provide are:
+0 for RECOMMENDED channels
+1 for TRENDING channels
+2 for POPULAR channels
+3 for NEW channels
+ Defaults to 0.
+
+
+
+
+
+ limit
+
+
+ number
+
+
+ Yes
+
+
+ The limit of found channels to be appear in the returnig result
+ Defaults to 50.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+
+
+
+
+
+
+ async
searchMessages (query[, options]) → Promise containing Array of Message Searches for messages
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ query
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ options
+
+
+ Object
+
+
+ Yes
+
+
+ Values in options have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ page
+
+
+ number
+
+
+ Yes
+
+
+
+
+
+
+
+ limit
+
+
+ number
+
+
+ Yes
+
+
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+ Yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Array of Message
+
+
+
+
+
+ async
sendChannelAdminInvite (chatId, channelId, options) → Promise containing boolean Sends a channel admin invitation to a user, allowing them to become an admin of the channel
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ The ID of a user to send the channel admin invitation to
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The ID of a channel for which the invitation is being sent
+
+
+
+
+
+ options
+
+
+ SendChannelAdminInviteOptions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if an invitation was sent successfully, false otherwise
+
+
+
+
+
+ async
sendMessage (chatId, content[, options]) → Promise containing Message Send a message to a specific chatId
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Message
Message that was just sent
+
+
+
+
+
+ async
sendPresenceAvailable () Marks the client as online
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
sendPresenceUnavailable () Marks the client as unavailable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
sendSeen (chatId) → Promise containing boolean Mark as seen for the Chat
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
result
+
+
+
+
+
+ async
setAutoDownloadAudio (flag) Setting autoload download audio
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ flag
+
+
+ boolean
+
+
+
+
+
+ true/false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
setAutoDownloadDocuments (flag) Setting autoload download documents
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ flag
+
+
+ boolean
+
+
+
+
+
+ true/false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
setAutoDownloadPhotos (flag) Setting autoload download photos
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ flag
+
+
+ boolean
+
+
+
+
+
+ true/false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
setAutoDownloadVideos (flag) Setting autoload download videos
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ flag
+
+
+ boolean
+
+
+
+
+
+ true/false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
setBackgroundSync (flag) → Promise containing boolean Setting background synchronization.
+NOTE: this action will take effect after you restart the client.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ flag
+
+
+ boolean
+
+
+
+
+
+ true/false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
+
+
+
+
+
+ async
setDisplayName (displayName) → Promise containing Boolean Sets the current user's display name.
+This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ displayName
+
+
+ string
+
+
+
+
+
+ New display name
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing Boolean
+
+
+
+
+
+ async
setProfilePicture (media) → Promise containing boolean Sets the current user's profile picture.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ media
+
+
+ MessageMedia
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the picture was properly updated.
+
+
+
+
+
+ async
setStatus (status) Sets the current user's status message
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ status
+
+
+ string
+
+
+
+
+
+ New status message
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ async
subscribeToChannel (channelId) → Promise containing boolean Subscribe to channel
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The channel ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
syncHistory (chatId) → Promise containing boolean Sync chat history conversation
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
True if operation completed successfully, false otherwise.
+
+
+
+
+
+ async
transferChannelOwnership (channelId, newOwnerId, options) → Promise containing boolean Transfers a channel ownership to another user.
+Note: the user you are transferring the channel ownership to must be a channel admin.
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ newOwnerId
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ options
+
+
+ TransferChannelOwnershipOptions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+ async
unarchiveChat () → boolean Changes and returns the archive state of the Chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ boolean
+
+
+
+
+
+ async
unmuteChat (chatId) → Promise containing {isMuted: boolean, muteExpiration: number} Unmutes the Chat
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ ID of the chat that will be unmuted
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing {isMuted: boolean, muteExpiration: number}
+
+
+
+
+
+ async
unpinChat () → Promise containing boolean Unpins the Chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
New pin state
+
+
+
+
+
+ async
unsubscribeFromChannel (channelId, options) → Promise containing boolean Unsubscribe from channel
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ channelId
+
+
+ string
+
+
+
+
+
+ The channel ID
+
+
+
+
+
+ options
+
+
+ UnsubscribeOptions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns
+ Promise containing boolean
Returns true if the operation completed successfully, false otherwise
+
+
+
+
+
+
+
+
+
+
+ Events
+
+ auth_failure Emitted when there has been an error while trying to restore an existing session
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ authenticated Emitted when authentication is successful
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ change_battery Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ batteryInfo
+
+
+ object
+
+
+
+
+
+ Values in batteryInfo have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ battery
+
+
+ number
+
+
+
+
+
+ The current battery percentage
+
+
+
+
+
+ plugged
+
+
+ boolean
+
+
+
+
+
+ Indicates if the phone is plugged in (true) or not (false)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Deprecated
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ change_state Emitted when the connection state changes
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ state
+
+
+ WAState
+
+
+
+
+
+ the new connection state
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ chat_archived Emitted when a chat is archived/unarchived
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chat
+
+
+ Chat
+
+
+
+
+
+
+
+
+
+
+ currState
+
+
+ boolean
+
+
+
+
+
+
+
+
+
+
+ prevState
+
+
+ boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ chat_removed Emitted when a chat is removed
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chat
+
+
+ Chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Emitted when a contact or a group participant changes their phone number.
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ Message with more information about the event.
+
+
+
+
+
+ oldId
+
+
+ String
+
+
+
+
+
+ The user's id (an old one) who changed their phone number
+and who triggered the notification.
+
+
+
+
+
+ newId
+
+
+ String
+
+
+
+
+
+ The user's new id after the change.
+
+
+
+
+
+ isContact
+
+
+ Boolean
+
+
+
+
+
+ Indicates if a contact or a group participant changed their phone number.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ disconnected Emitted when the client has been disconnected
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ reason
+
+
+ (WAState or "LOGOUT")
+
+
+
+
+
+ reason that caused the disconnect
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group_admin_changed Emitted when a current user is promoted to an admin or demoted to a regular user.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ notification
+
+
+ GroupNotification
+
+
+
+
+
+ GroupNotification with more information about the action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group_join Emitted when a user joins the chat via invite link or is added by an admin.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ notification
+
+
+ GroupNotification
+
+
+
+
+
+ GroupNotification with more information about the action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group_leave Emitted when a user leaves the chat or is removed by an admin.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ notification
+
+
+ GroupNotification
+
+
+
+
+
+ GroupNotification with more information about the action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group_membership_request Emitted when some user requested to join the group
+that has the membership approval mode turned on
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ notification
+
+
+ GroupNotification
+
+
+
+
+
+ GroupNotification with more information about the action
+ Values in notification have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ chatId
+
+
+ string
+
+
+
+
+
+ The group ID the request was made for
+
+
+
+
+
+ author
+
+
+ string
+
+
+
+
+
+ The user ID that made a request
+
+
+
+
+
+ timestamp
+
+
+ number
+
+
+
+
+
+ The timestamp the request was made at
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ group_update Emitted when group settings are updated, such as subject, description or picture.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ notification
+
+
+ GroupNotification
+
+
+
+
+
+ GroupNotification with more information about the action
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ incoming_call Emitted when a call is received
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ call
+
+
+ object
+
+
+
+
+
+ Values in call have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ id
+
+
+ number
+
+
+
+
+
+ Call id
+
+
+
+
+
+ peerJid
+
+
+ string
+
+
+
+
+
+ Who called
+
+
+
+
+
+ isVideo
+
+
+ boolean
+
+
+
+
+
+ if is video
+
+
+
+
+
+ isGroup
+
+
+ boolean
+
+
+
+
+
+ if is group
+
+
+
+
+
+ canHandleLocally
+
+
+ boolean
+
+
+
+
+
+ if we can handle in waweb
+
+
+
+
+
+ outgoing
+
+
+ boolean
+
+
+
+
+
+ if is outgoing
+
+
+
+
+
+ webClientShouldHandle
+
+
+ boolean
+
+
+
+
+
+ If Waweb should handle
+
+
+
+
+
+ participants
+
+
+ object
+
+
+
+
+
+ Participants
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Emitted when media has been uploaded for a message sent by the client.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message with media that was uploaded
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message Emitted when a new message is received.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message that was received
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_ack Emitted when an ack event occurrs on message type.
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message that was affected
+
+
+
+
+
+ ack
+
+
+ MessageAck
+
+
+
+
+
+ The new ACK value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_ciphertext Emitted when messages are edited
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_create Emitted when a new message is created, which may include the current user's own messages.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message that was created
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_edit Emitted when messages are edited
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+
+
+
+
+
+ newBody
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+ prevBody
+
+
+ string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_reaction Emitted when a reaction is sent, received, updated or removed
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ reaction
+
+
+ object
+
+
+
+
+
+ Values in reaction have the following properties:
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ id
+
+
+ object
+
+
+
+
+
+ Reaction id
+
+
+
+
+
+ orphan
+
+
+ number
+
+
+
+
+
+ Orphan
+
+
+
+
+
+ orphanReason
+
+
+ string
+
+
+
+
+
+ Orphan reason
+ Value can be null.
+
+
+
+
+
+ timestamp
+
+
+ number
+
+
+
+
+
+ Timestamp
+
+
+
+
+
+ reaction
+
+
+ string
+
+
+
+
+
+ Reaction
+
+
+
+
+
+ read
+
+
+ boolean
+
+
+
+
+
+ Read
+
+
+
+
+
+ msgId
+
+
+ object
+
+
+
+
+
+ Parent message id
+
+
+
+
+
+ senderId
+
+
+ string
+
+
+
+
+
+ Sender id
+
+
+
+
+
+ ack
+
+
+ number
+
+
+
+
+
+ Ack
+ Value can be null.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_revoke_everyone Emitted when a message is deleted for everyone in the chat.
+
+
+
+ Parameters
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message that was revoked, in its current state. It will not contain the original message's data.
+
+
+
+
+
+ revoked_msg
+
+
+ Message
+
+
+
+
+
+ The message that was revoked, before it was revoked. It will contain the message's original data.
+Note that due to the way this data is captured, it may be possible that this param will be undefined.
+ Value can be null.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ message_revoke_me Emitted when a message is deleted by the current user.
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ message
+
+
+ Message
+
+
+
+
+
+ The message that was revoked
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ qr Emitted when a QR code is received
+
+
+
+ Parameter
+
+
+
+ Name
+ Type
+ Optional
+ Description
+
+
+
+
+
+ qr
+
+
+ string
+
+
+
+
+
+ QR Code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ready Emitted when the client has initialized and is ready to receive messages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ vote_update Emitted when some poll option is selected or deselected,
+shows a user's current selected option(s) on the poll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/Client.js.html b/docs/Client.js.html
index 038e3d7..a3050d8 100644
--- a/docs/Client.js.html
+++ b/docs/Client.js.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.28.1-alpha.0 » Source: Client.js
+
whatsapp-web.js 1.29.0 » Source: Client.js
@@ -15,7 +15,7 @@
@@ -46,7 +46,7 @@ const { LoadUtils } = require('./util/Injected/Utils');
const ChatFactory = require('./factories/ChatFactory');
const ContactFactory = require('./factories/ContactFactory');
const WebCacheFactory = require('./webCache/WebCacheFactory');
-const { ClientInfo, Message, MessageMedia, Contact, Location, Poll, PollVote, GroupNotification, Label, Call, Buttons, List, Reaction, Broadcast} = require('./structures');
+const { Broadcast, Buttons, Call, ClientInfo, Contact, GroupNotification, Label, List, Location, Message, MessageMedia, Poll, PollVote, Reaction } = require('./structures');
const NoAuth = require('./authStrategies/NoAuth');
const {exposeFunctionIfAbsent} = require('./util/Puppeteer');
@@ -851,11 +851,9 @@ class Client extends EventEmitter {
*
*/
async sendSeen(chatId) {
- const result = await this.pupPage.evaluate(async (chatId) => {
+ return await this.pupPage.evaluate(async (chatId) => {
return window.WWebJS.sendSeen(chatId);
-
}, chatId);
- return result;
}
/**
@@ -885,6 +883,7 @@ class Client extends EventEmitter {
* @property {string} [stickerName=undefined] - Sets the name of the sticker, (if sendMediaAsSticker is true).
* @property {string[]} [stickerCategories=undefined] - Sets the categories of the sticker, (if sendMediaAsSticker is true). Provide emoji char array, can be null.
* @property {MessageMedia} [media] - Media to be sent
+ * @property {any} [extra] - Extra options
*/
/**
@@ -896,6 +895,19 @@ class Client extends EventEmitter {
* @returns {Promise<Message>} Message that was just sent
*/
async sendMessage(chatId, content, options = {}) {
+ const isChannel = /@\w*newsletter\b/.test(chatId);
+
+ if (isChannel && [
+ options.sendMediaAsDocument, options.quotedMessageId,
+ options.parseVCards, options.isViewOnce,
+ content instanceof Location, content instanceof Contact,
+ content instanceof Buttons, content instanceof List,
+ Array.isArray(content) && content.length > 0 && content[0] instanceof Contact
+ ].includes(true)) {
+ console.warn('The message type is currently not supported for sending in channels,\nthe supported message types are: text, image, sticker, gif, video, voice and poll.');
+ return null;
+ }
+
if (options.mentions) {
!Array.isArray(options.mentions) && (options.mentions = [options.mentions]);
if (options.mentions.some((possiblyContact) => possiblyContact instanceof Contact)) {
@@ -905,7 +917,7 @@ class Client extends EventEmitter {
}
options.groupMentions && !Array.isArray(options.groupMentions) && (options.groupMentions = [options.groupMentions]);
-
+
let internalOptions = {
linkPreview: options.linkPreview === false ? undefined : true,
sendAudioAsVoice: options.sendAudioAsVoice,
@@ -921,14 +933,14 @@ class Client extends EventEmitter {
extraOptions: options.extra
};
- const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
+ const sendSeen = options.sendSeen !== false;
if (content instanceof MessageMedia) {
- internalOptions.attachment = content;
+ internalOptions.media = content;
internalOptions.isViewOnce = options.isViewOnce,
content = '';
} else if (options.media instanceof MessageMedia) {
- internalOptions.attachment = options.media;
+ internalOptions.media = options.media;
internalOptions.caption = content;
internalOptions.isViewOnce = options.isViewOnce,
content = '';
@@ -945,17 +957,19 @@ class Client extends EventEmitter {
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
content = '';
} else if (content instanceof Buttons) {
+ console.warn('Buttons are now deprecated. See more at https://www.youtube.com/watch?v=hv1R1rLeVVE.');
if (content.type !== 'chat') { internalOptions.attachment = content.body; }
internalOptions.buttons = content;
content = '';
} else if (content instanceof List) {
+ console.warn('Lists are now deprecated. See more at https://www.youtube.com/watch?v=hv1R1rLeVVE.');
internalOptions.list = content;
content = '';
}
- if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
- internalOptions.attachment = await Util.formatToWebpSticker(
- internalOptions.attachment, {
+ if (internalOptions.sendMediaAsSticker && internalOptions.media) {
+ internalOptions.media = await Util.formatToWebpSticker(
+ internalOptions.media, {
name: options.stickerName,
author: options.stickerAuthor,
categories: options.stickerCategories
@@ -963,20 +977,60 @@ class Client extends EventEmitter {
);
}
- const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
- const chatWid = window.Store.WidFactory.createWid(chatId);
- const chat = await window.Store.Chat.find(chatWid);
+ const sentMsg = await this.pupPage.evaluate(async (chatId, content, options, sendSeen) => {
+ const chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
+ if (!chat) return null;
if (sendSeen) {
await window.WWebJS.sendSeen(chatId);
}
- const msg = await window.WWebJS.sendMessage(chat, message, options, sendSeen);
- return window.WWebJS.getMessageModel(msg);
+ const msg = await window.WWebJS.sendMessage(chat, content, options);
+ return msg
+ ? window.WWebJS.getMessageModel(msg)
+ : undefined;
}, chatId, content, internalOptions, sendSeen);
- return new Message(this, newMessage);
+ return sentMsg
+ ? new Message(this, sentMsg)
+ : undefined;
+ }
+
+ /**
+ * @typedef {Object} SendChannelAdminInviteOptions
+ * @property {?string} comment The comment to be added to an invitation
+ */
+
+ /**
+ * Sends a channel admin invitation to a user, allowing them to become an admin of the channel
+ * @param {string} chatId The ID of a user to send the channel admin invitation to
+ * @param {string} channelId The ID of a channel for which the invitation is being sent
+ * @param {SendChannelAdminInviteOptions} options
+ * @returns {Promise<boolean>} Returns true if an invitation was sent successfully, false otherwise
+ */
+ async sendChannelAdminInvite(chatId, channelId, options = {}) {
+ const response = await this.pupPage.evaluate(async (chatId, channelId, options) => {
+ const channelWid = window.Store.WidFactory.createWid(channelId);
+ const chatWid = window.Store.WidFactory.createWid(chatId);
+ const chat = window.Store.Chat.get(chatWid) || (await window.Store.Chat.find(chatWid));
+
+ if (!chatWid.isUser()) {
+ return false;
+ }
+
+ return await window.Store.SendChannelMessage.sendNewsletterAdminInviteMessage(
+ chat,
+ {
+ newsletterWid: channelWid,
+ invitee: chatWid,
+ inviteMessage: options.comment,
+ base64Thumb: await window.WWebJS.getProfilePicThumbToBase64(channelWid)
+ }
+ );
+ }, chatId, channelId, options);
+
+ return response.messageSendResult === 'OK';
}
/**
@@ -1002,7 +1056,7 @@ class Client extends EventEmitter {
* @returns {Promise<Array<Chat>>}
*/
async getChats() {
- let chats = await this.pupPage.evaluate(async () => {
+ const chats = await this.pupPage.evaluate(async () => {
return await window.WWebJS.getChats();
});
@@ -1010,16 +1064,51 @@ class Client extends EventEmitter {
}
/**
- * Get chat instance by ID
+ * Gets all cached {@link Channel} instance
+ * @returns {Promise<Array<Channel>>}
+ */
+ async getChannels() {
+ const channels = await this.pupPage.evaluate(async () => {
+ return await window.WWebJS.getChannels();
+ });
+
+ return channels.map((channel) => ChatFactory.create(this, channel));
+ }
+
+ /**
+ * Gets chat or channel instance by ID
* @param {string} chatId
- * @returns {Promise<Chat>}
+ * @returns {Promise<Chat|Channel>}
*/
async getChatById(chatId) {
- let chat = await this.pupPage.evaluate(async chatId => {
+ const chat = await this.pupPage.evaluate(async chatId => {
return await window.WWebJS.getChat(chatId);
}, chatId);
+ return chat
+ ? ChatFactory.create(this, chat)
+ : undefined;
+ }
- return ChatFactory.create(this, chat);
+ /**
+ * Gets a {@link Channel} instance by invite code
+ * @param {string} inviteCode The code that comes after the 'https://whatsapp.com/channel/'
+ * @returns {Promise<Channel>}
+ */
+ async getChannelByInviteCode(inviteCode) {
+ const channel = await this.pupPage.evaluate(async (inviteCode) => {
+ let channelMetadata;
+ try {
+ channelMetadata = await window.WWebJS.getChannelMetadata(inviteCode);
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') return null;
+ throw err;
+ }
+ return await window.WWebJS.getChat(channelMetadata.id);
+ }, inviteCode);
+
+ return channel
+ ? ChatFactory.create(this, channel)
+ : undefined;
}
/**
@@ -1089,6 +1178,61 @@ class Client extends EventEmitter {
return res.gid._serialized;
}
+ /**
+ * Accepts a channel admin invitation and promotes the current user to a channel admin
+ * @param {string} channelId The channel ID to accept the admin invitation from
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async acceptChannelAdminInvite(channelId) {
+ return await this.pupPage.evaluate(async (channelId) => {
+ try {
+ await window.Store.ChannelUtils.acceptNewsletterAdminInvite(channelId);
+ return true;
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ }, channelId);
+ }
+
+ /**
+ * Revokes a channel admin invitation sent to a user by a channel owner
+ * @param {string} channelId The channel ID an invitation belongs to
+ * @param {string} userId The user ID the invitation was sent to
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async revokeChannelAdminInvite(channelId, userId) {
+ return await this.pupPage.evaluate(async (channelId, userId) => {
+ try {
+ const userWid = window.Store.WidFactory.createWid(userId);
+ await window.Store.ChannelUtils.revokeNewsletterAdminInvite(channelId, userWid);
+ return true;
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ }, channelId, userId);
+ }
+
+ /**
+ * Demotes a channel admin to a regular subscriber (can be used also for self-demotion)
+ * @param {string} channelId The channel ID to demote an admin in
+ * @param {string} userId The user ID to demote
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async demoteChannelAdmin(channelId, userId) {
+ return await this.pupPage.evaluate(async (channelId, userId) => {
+ try {
+ const userWid = window.Store.WidFactory.createWid(userId);
+ await window.Store.ChannelUtils.demoteNewsletterAdmin(channelId, userWid);
+ return true;
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ }, channelId, userId);
+ }
+
/**
* Accepts a private invitation to join a group
* @param {object} inviteInfo Invite V4 Info
@@ -1165,7 +1309,7 @@ class Client extends EventEmitter {
*/
async archiveChat(chatId) {
return await this.pupPage.evaluate(async chatId => {
- let chat = await window.Store.Chat.get(chatId);
+ let chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.archiveChat(chat, true);
return true;
}, chatId);
@@ -1177,7 +1321,7 @@ class Client extends EventEmitter {
*/
async unarchiveChat(chatId) {
return await this.pupPage.evaluate(async chatId => {
- let chat = await window.Store.Chat.get(chatId);
+ let chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.archiveChat(chat, false);
return false;
}, chatId);
@@ -1189,7 +1333,7 @@ class Client extends EventEmitter {
*/
async pinChat(chatId) {
return this.pupPage.evaluate(async chatId => {
- let chat = window.Store.Chat.get(chatId);
+ let chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
if (chat.pin) {
return true;
}
@@ -1212,7 +1356,7 @@ class Client extends EventEmitter {
*/
async unpinChat(chatId) {
return this.pupPage.evaluate(async chatId => {
- let chat = window.Store.Chat.get(chatId);
+ let chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
if (!chat.pin) {
return false;
}
@@ -1264,7 +1408,7 @@ class Client extends EventEmitter {
*/
async markChatUnread(chatId) {
await this.pupPage.evaluate(async chatId => {
- let chat = await window.Store.Chat.get(chatId);
+ let chat = await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.markChatUnread(chat, true);
}, chatId);
}
@@ -1466,7 +1610,7 @@ class Client extends EventEmitter {
for (const participant of createGroupResult.participants) {
let isInviteV4Sent = false;
const participantId = participant.wid._serialized;
- const statusCode = participant.error ?? 200;
+ const statusCode = participant.error || 200;
if (autoSendInviteV4 && statusCode === 403) {
window.Store.Contact.gadd(participant.wid, { silent: true });
@@ -1505,6 +1649,219 @@ class Client extends EventEmitter {
}, title, participants, options);
}
+ /**
+ * An object that handles the result for {@link createChannel} method
+ * @typedef {Object} CreateChannelResult
+ * @property {string} title A channel title
+ * @property {ChatId} nid An object that handels the newly created channel ID
+ * @property {string} nid.server 'newsletter'
+ * @property {string} nid.user 'XXXXXXXXXX'
+ * @property {string} nid._serialized 'XXXXXXXXXX@newsletter'
+ * @property {string} inviteLink The channel invite link, starts with 'https://whatsapp.com/channel/'
+ * @property {number} createdAtTs The timestamp the channel was created at
+ */
+
+ /**
+ * Options for the channel creation
+ * @typedef {Object} CreateChannelOptions
+ * @property {?string} description The channel description
+ * @property {?MessageMedia} picture The channel profile picture
+ */
+
+ /**
+ * Creates a new channel
+ * @param {string} title The channel name
+ * @param {CreateChannelOptions} options
+ * @returns {Promise<CreateChannelResult|string>} Returns an object that handles the result for the channel creation or an error message as a string
+ */
+ async createChannel(title, options = {}) {
+ return await this.pupPage.evaluate(async (title, options) => {
+ let response, { description = null, picture = null } = options;
+
+ if (!window.Store.ChannelUtils.isNewsletterCreationEnabled()) {
+ return 'CreateChannelError: A channel creation is not enabled';
+ }
+
+ if (picture) {
+ picture = await window.WWebJS.cropAndResizeImage(picture, {
+ asDataUrl: true,
+ mimetype: 'image/jpeg',
+ size: 640,
+ quality: 1
+ });
+ }
+
+ try {
+ response = await window.Store.ChannelUtils.createNewsletterQuery({
+ name: title,
+ description: description,
+ picture: picture,
+ });
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') {
+ return 'CreateChannelError: An error occupied while creating a channel';
+ }
+ throw err;
+ }
+
+ return {
+ title: title,
+ nid: window.Store.JidToWid.newsletterJidToWid(response.idJid),
+ inviteLink: `https://whatsapp.com/channel/${response.newsletterInviteLinkMetadataMixin.inviteCode}`,
+ createdAtTs: response.newsletterCreationTimeMetadataMixin.creationTimeValue
+ };
+ }, title, options);
+ }
+
+ /**
+ * Subscribe to channel
+ * @param {string} channelId The channel ID
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async subscribeToChannel(channelId) {
+ return await this.pupPage.evaluate(async (channelId) => {
+ return await window.WWebJS.subscribeToUnsubscribeFromChannel(channelId, 'Subscribe');
+ }, channelId);
+ }
+
+ /**
+ * Options for unsubscribe from a channel
+ * @typedef {Object} UnsubscribeOptions
+ * @property {boolean} [deleteLocalModels = false] If true, after an unsubscription, it will completely remove a channel from the channel collection making it seem like the current user have never interacted with it. Otherwise it will only remove a channel from the list of channels the current user is subscribed to and will set the membership type for that channel to GUEST
+ */
+
+ /**
+ * Unsubscribe from channel
+ * @param {string} channelId The channel ID
+ * @param {UnsubscribeOptions} options
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async unsubscribeFromChannel(channelId, options) {
+ return await this.pupPage.evaluate(async (channelId, options) => {
+ return await window.WWebJS.subscribeToUnsubscribeFromChannel(channelId, 'Unsubscribe', options);
+ }, channelId, options);
+ }
+
+ /**
+ * Options for transferring a channel ownership to another user
+ * @typedef {Object} TransferChannelOwnershipOptions
+ * @property {boolean} [shouldDismissSelfAsAdmin = false] If true, after the channel ownership is being transferred to another user, the current user will be dismissed as a channel admin and will become to a channel subscriber.
+ */
+
+ /**
+ * Transfers a channel ownership to another user.
+ * Note: the user you are transferring the channel ownership to must be a channel admin.
+ * @param {string} channelId
+ * @param {string} newOwnerId
+ * @param {TransferChannelOwnershipOptions} options
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async transferChannelOwnership(channelId, newOwnerId, options = {}) {
+ return await this.pupPage.evaluate(async (channelId, newOwnerId, options) => {
+ const channel = await window.WWebJS.getChat(channelId, { getAsModel: false });
+ const newOwner = window.Store.Contact.get(newOwnerId) || (await window.Store.Contact.find(newOwnerId));
+ if (!channel.newsletterMetadata) {
+ await window.Store.NewsletterMetadataCollection.update(channel.id);
+ }
+
+ try {
+ await window.Store.ChannelUtils.changeNewsletterOwnerAction(channel, newOwner);
+
+ if (options.shouldDismissSelfAsAdmin) {
+ const meContact = window.Store.ContactCollection.getMeContact();
+ meContact && (await window.Store.ChannelUtils.demoteNewsletterAdminAction(channel, meContact));
+ }
+ } catch (error) {
+ return false;
+ }
+
+ return true;
+ }, channelId, newOwnerId, options);
+ }
+
+ /**
+ * Searches for channels based on search criteria, there are some notes:
+ * 1. The method finds only channels you are not subscribed to currently
+ * 2. If you have never been subscribed to a found channel
+ * or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to 'true',
+ * the lastMessage property of a found channel will be 'null'
+ *
+ * @param {Object} searchOptions Search options
+ * @param {string} [searchOptions.searchText = ''] Text to search
+ * @param {Array<string>} [searchOptions.countryCodes = [your local region]] Array of country codes in 'ISO 3166-1 alpha-2' standart (@see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to search for channels created in these countries
+ * @param {boolean} [searchOptions.skipSubscribedNewsletters = false] If true, channels that user is subscribed to won't appear in found channels
+ * @param {number} [searchOptions.view = 0] View type, makes sense only when the searchText is empty. Valid values to provide are:
+ * 0 for RECOMMENDED channels
+ * 1 for TRENDING channels
+ * 2 for POPULAR channels
+ * 3 for NEW channels
+ * @param {number} [searchOptions.limit = 50] The limit of found channels to be appear in the returnig result
+ * @returns {Promise<Array<Channel>|[]>} Returns an array of Channel objects or an empty array if no channels were found
+ */
+ async searchChannels(searchOptions = {}) {
+ return await this.pupPage.evaluate(async ({
+ searchText = '',
+ countryCodes = [window.Store.ChannelUtils.currentRegion],
+ skipSubscribedNewsletters = false,
+ view = 0,
+ limit = 50
+ }) => {
+ searchText = searchText.trim();
+ const currentRegion = window.Store.ChannelUtils.currentRegion;
+ if (![0, 1, 2, 3].includes(view)) view = 0;
+
+ countryCodes = countryCodes.length === 1 && countryCodes[0] === currentRegion
+ ? countryCodes
+ : countryCodes.filter((code) => Object.keys(window.Store.ChannelUtils.countryCodesIso).includes(code));
+
+ const viewTypeMapping = {
+ 0: 'RECOMMENDED',
+ 1: 'TRENDING',
+ 2: 'POPULAR',
+ 3: 'NEW'
+ };
+
+ searchOptions = {
+ searchText: searchText,
+ countryCodes: countryCodes,
+ skipSubscribedNewsletters: skipSubscribedNewsletters,
+ view: viewTypeMapping[view],
+ categories: [],
+ cursorToken: ''
+ };
+
+ const originalFunction = window.Store.ChannelUtils.getNewsletterDirectoryPageSize;
+ limit !== 50 && (window.Store.ChannelUtils.getNewsletterDirectoryPageSize = () => limit);
+
+ const channels = (await window.Store.ChannelUtils.fetchNewsletterDirectories(searchOptions)).newsletters;
+
+ limit !== 50 && (window.Store.ChannelUtils.getNewsletterDirectoryPageSize = originalFunction);
+
+ return channels
+ ? await Promise.all(channels.map((channel) => window.WWebJS.getChatModel(channel, { isChannel: true })))
+ : [];
+ }, searchOptions);
+ }
+
+ /**
+ * Deletes the channel you created
+ * @param {string} channelId The ID of a channel to delete
+ * @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
+ */
+ async deleteChannel(channelId) {
+ return await this.client.pupPage.evaluate(async (channelId) => {
+ const channel = await window.WWebJS.getChat(channelId, { getAsModel: false });
+ if (!channel) return false;
+ try {
+ await window.Store.ChannelUtils.deleteNewsletterAction(channel);
+ return true;
+ } catch (err) {
+ if (err.name === 'ServerStatusCodeError') return false;
+ throw err;
+ }
+ }, channelId);
+ }
+
/**
* Get all current Labels
* @returns {Promise<Array<Label>>}
@@ -1863,7 +2220,7 @@ module.exports = Client;
diff --git a/docs/ClientInfo.html b/docs/ClientInfo.html
index 069dcbc..b50dd6c 100644
--- a/docs/ClientInfo.html
+++ b/docs/ClientInfo.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.28.1-alpha.0 » Class: ClientInfo
+
whatsapp-web.js 1.29.0 » Class: ClientInfo
@@ -15,7 +15,7 @@
@@ -242,7 +242,7 @@
diff --git a/docs/Contact.html b/docs/Contact.html
index d82e377..859f078 100644
--- a/docs/Contact.html
+++ b/docs/Contact.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.28.1-alpha.0 » Class: Contact
+
whatsapp-web.js 1.29.0 » Class: Contact
@@ -15,7 +15,7 @@
@@ -293,7 +293,7 @@
diff --git a/docs/GroupChat.html b/docs/GroupChat.html
index 0d8cfbe..10d3bca 100644
--- a/docs/GroupChat.html
+++ b/docs/GroupChat.html
@@ -4,7 +4,7 @@
-
whatsapp-web.js 1.28.1-alpha.0 » Class: GroupChat
+
whatsapp-web.js 1.29.0 » Class: GroupChat
@@ -15,7 +15,7 @@
@@ -470,7 +470,7 @@
async
-
clearMessages () → Promise containing Boolean
+
clearMessages () → Promise containing boolean
Clears all messages from the chat
Inherited from
@@ -914,7 +914,7 @@
async
sendSeen () → Promise containing Boolean
-
Set the chat as seen
+
Sets the chat as seen
Inherited from
Chat#sendSeen
@@ -1225,7 +1225,7 @@
diff --git a/docs/GroupNotification.html b/docs/GroupNotification.html
index eb950da..424ebd7 100644
--- a/docs/GroupNotification.html
+++ b/docs/GroupNotification.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: GroupNotification
+ whatsapp-web.js 1.29.0 » Class: GroupNotification
@@ -15,7 +15,7 @@
@@ -233,7 +233,7 @@
diff --git a/docs/InterfaceController.html b/docs/InterfaceController.html
index 6c23bc9..100e7ca 100644
--- a/docs/InterfaceController.html
+++ b/docs/InterfaceController.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: InterfaceController
+ whatsapp-web.js 1.29.0 » Class: InterfaceController
@@ -15,7 +15,7 @@
@@ -382,7 +382,7 @@
diff --git a/docs/Label.html b/docs/Label.html
index 2c4aef7..ef87ad1 100644
--- a/docs/Label.html
+++ b/docs/Label.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Label
+ whatsapp-web.js 1.29.0 » Class: Label
@@ -15,7 +15,7 @@
@@ -163,7 +163,7 @@
diff --git a/docs/List.html b/docs/List.html
index 7bb5bf5..94c6648 100644
--- a/docs/List.html
+++ b/docs/List.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: List
+ whatsapp-web.js 1.29.0 » Class: List
@@ -15,7 +15,7 @@
@@ -256,7 +256,7 @@ Returns: [{'title':'sectionTitle','rows':[{'r
diff --git a/docs/LocalAuth.html b/docs/LocalAuth.html
index 0d0521f..19c9b29 100644
--- a/docs/LocalAuth.html
+++ b/docs/LocalAuth.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: LocalAuth
+ whatsapp-web.js 1.29.0 » Class: LocalAuth
@@ -15,7 +15,7 @@
@@ -134,7 +134,7 @@
diff --git a/docs/LocalWebCache.html b/docs/LocalWebCache.html
index 2f96226..c66afb6 100644
--- a/docs/LocalWebCache.html
+++ b/docs/LocalWebCache.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: LocalWebCache
+ whatsapp-web.js 1.29.0 » Class: LocalWebCache
@@ -15,7 +15,7 @@
@@ -120,7 +120,7 @@
diff --git a/docs/Location.html b/docs/Location.html
index 9e2fc00..97c31db 100644
--- a/docs/Location.html
+++ b/docs/Location.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Location
+ whatsapp-web.js 1.29.0 » Class: Location
@@ -15,7 +15,7 @@
@@ -173,7 +173,7 @@
diff --git a/docs/Message.html b/docs/Message.html
index 31aab63..5db8ffb 100644
--- a/docs/Message.html
+++ b/docs/Message.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Message
+ whatsapp-web.js 1.29.0 » Class: Message
@@ -15,7 +15,7 @@
@@ -815,7 +815,7 @@
diff --git a/docs/MessageMedia.html b/docs/MessageMedia.html
index 55d7357..11f54bf 100644
--- a/docs/MessageMedia.html
+++ b/docs/MessageMedia.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: MessageMedia
+ whatsapp-web.js 1.29.0 » Class: MessageMedia
@@ -15,7 +15,7 @@
@@ -364,7 +364,7 @@
diff --git a/docs/NoAuth.html b/docs/NoAuth.html
index 54df7ce..333e7b3 100644
--- a/docs/NoAuth.html
+++ b/docs/NoAuth.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: NoAuth
+ whatsapp-web.js 1.29.0 » Class: NoAuth
@@ -15,7 +15,7 @@
@@ -51,7 +51,7 @@
diff --git a/docs/Order.html b/docs/Order.html
index a2d769b..854c5f7 100644
--- a/docs/Order.html
+++ b/docs/Order.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Order
+ whatsapp-web.js 1.29.0 » Class: Order
@@ -15,7 +15,7 @@
@@ -102,7 +102,7 @@
diff --git a/docs/Poll.html b/docs/Poll.html
index d547d62..5b93517 100644
--- a/docs/Poll.html
+++ b/docs/Poll.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Poll
+ whatsapp-web.js 1.29.0 » Class: Poll
@@ -15,7 +15,7 @@
@@ -148,7 +148,7 @@
diff --git a/docs/PollVote.html b/docs/PollVote.html
index 9639652..b4417a9 100644
--- a/docs/PollVote.html
+++ b/docs/PollVote.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: PollVote
+ whatsapp-web.js 1.29.0 » Class: PollVote
@@ -15,7 +15,7 @@
@@ -104,7 +104,7 @@
diff --git a/docs/PrivateChat.html b/docs/PrivateChat.html
index f7e0b9e..bd21961 100644
--- a/docs/PrivateChat.html
+++ b/docs/PrivateChat.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: PrivateChat
+ whatsapp-web.js 1.29.0 » Class: PrivateChat
@@ -15,7 +15,7 @@
@@ -294,7 +294,7 @@
async
-
clearMessages () → Promise containing Boolean
+
clearMessages () → Promise containing boolean
Clears all messages from the chat
Inherited from
@@ -530,7 +530,7 @@
async
sendSeen () → Promise containing Boolean
-
Set the chat as seen
+
Sets the chat as seen
Inherited from
Chat#sendSeen
@@ -601,7 +601,7 @@
diff --git a/docs/PrivateContact.html b/docs/PrivateContact.html
index a3c56a4..04d8fa8 100644
--- a/docs/PrivateContact.html
+++ b/docs/PrivateContact.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: PrivateContact
+ whatsapp-web.js 1.29.0 » Class: PrivateContact
@@ -15,7 +15,7 @@
@@ -319,7 +319,7 @@
diff --git a/docs/Product.html b/docs/Product.html
index bca325d..67191e5 100644
--- a/docs/Product.html
+++ b/docs/Product.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Product
+ whatsapp-web.js 1.29.0 » Class: Product
@@ -15,7 +15,7 @@
@@ -127,7 +127,7 @@
diff --git a/docs/Reaction.html b/docs/Reaction.html
index 65e3693..6965fbf 100644
--- a/docs/Reaction.html
+++ b/docs/Reaction.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Reaction
+ whatsapp-web.js 1.29.0 » Class: Reaction
@@ -15,7 +15,7 @@
@@ -144,7 +144,7 @@
diff --git a/docs/RemoteAuth.html b/docs/RemoteAuth.html
index 15eb227..0892a44 100644
--- a/docs/RemoteAuth.html
+++ b/docs/RemoteAuth.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: RemoteAuth
+ whatsapp-web.js 1.29.0 » Class: RemoteAuth
@@ -15,7 +15,7 @@
@@ -162,7 +162,7 @@
diff --git a/docs/RemoteWebCache.html b/docs/RemoteWebCache.html
index 28a498f..3505015 100644
--- a/docs/RemoteWebCache.html
+++ b/docs/RemoteWebCache.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: RemoteWebCache
+ whatsapp-web.js 1.29.0 » Class: RemoteWebCache
@@ -15,7 +15,7 @@
@@ -120,7 +120,7 @@
diff --git a/docs/Util.html b/docs/Util.html
index 3e06b0a..dbd4bb1 100644
--- a/docs/Util.html
+++ b/docs/Util.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: Util
+ whatsapp-web.js 1.29.0 » Class: Util
@@ -15,7 +15,7 @@
@@ -243,7 +243,7 @@
diff --git a/docs/WebCache.html b/docs/WebCache.html
index 189b3df..825b4b0 100644
--- a/docs/WebCache.html
+++ b/docs/WebCache.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Class: WebCache
+ whatsapp-web.js 1.29.0 » Class: WebCache
@@ -15,7 +15,7 @@
@@ -50,7 +50,7 @@
diff --git a/docs/authStrategies_BaseAuthStrategy.js.html b/docs/authStrategies_BaseAuthStrategy.js.html
index df78539..ac81c7f 100644
--- a/docs/authStrategies_BaseAuthStrategy.js.html
+++ b/docs/authStrategies_BaseAuthStrategy.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Source: authStrategies/BaseAuthStrategy.js
+ whatsapp-web.js 1.29.0 » Source: authStrategies/BaseAuthStrategy.js
@@ -15,7 +15,7 @@
@@ -65,7 +65,7 @@ module.exports = BaseAuthStrategy;
diff --git a/docs/authStrategies_LocalAuth.js.html b/docs/authStrategies_LocalAuth.js.html
index db9eb43..523c0ef 100644
--- a/docs/authStrategies_LocalAuth.js.html
+++ b/docs/authStrategies_LocalAuth.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Source: authStrategies/LocalAuth.js
+ whatsapp-web.js 1.29.0 » Source: authStrategies/LocalAuth.js
@@ -15,7 +15,7 @@
@@ -97,7 +97,7 @@ module.exports = LocalAuth;
diff --git a/docs/authStrategies_NoAuth.js.html b/docs/authStrategies_NoAuth.js.html
index 554e705..f3ea99a 100644
--- a/docs/authStrategies_NoAuth.js.html
+++ b/docs/authStrategies_NoAuth.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Source: authStrategies/NoAuth.js
+ whatsapp-web.js 1.29.0 » Source: authStrategies/NoAuth.js
@@ -15,7 +15,7 @@
@@ -50,7 +50,7 @@ module.exports = NoAuth;
diff --git a/docs/authStrategies_RemoteAuth.js.html b/docs/authStrategies_RemoteAuth.js.html
index 27b54ac..9c57bdf 100644
--- a/docs/authStrategies_RemoteAuth.js.html
+++ b/docs/authStrategies_RemoteAuth.js.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Source: authStrategies/RemoteAuth.js
+ whatsapp-web.js 1.29.0 » Source: authStrategies/RemoteAuth.js
@@ -15,7 +15,7 @@
@@ -249,7 +249,7 @@ module.exports = RemoteAuth;
diff --git a/docs/global.html b/docs/global.html
index 2549b8e..af47a5d 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -4,7 +4,7 @@
- whatsapp-web.js 1.28.1-alpha.0 » Globals
+ whatsapp-web.js 1.29.0 » Globals
@@ -15,7 +15,7 @@
@@ -93,9 +93,18 @@
ButtonSpec
+ ChannelId
+
+
ContactId
+ CreateChannelOptions
+
+
+ CreateChannelResult
+
+
CreateGroupOptions
@@ -142,16 +151,19 @@
Mention
-
-
- Sticker metadata.
@@ -3685,6 +4099,111 @@
@@ -653,6 +653,178 @@ limitations under the License.
+