Skip to main content

Class: Client

api/Client.Client

Methods​

B
insiders
​

β–Έ B(chatId, payload): Promise<MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Use a raw payload within your open-wa session

Parameters​

NameTypeDescription
chatIdChatId
payloadObject{any} returns: MessageId

Returns​

Promise<MessageId>


addLabel​

β–Έ addLabel(label, chatId): Promise<boolean>

Adds label from chat, message or contact. Only for business accounts.

Parameters​

NameType
labelstring
chatIdChatId

Returns​

Promise<boolean>


addParticipant​

β–Έ addParticipant(groupId, participantId): Promise<boolean>

Add participant to Group

If not a group chat, returns NOT_A_GROUP_CHAT.

If the chat does not exist, returns GROUP_DOES_NOT_EXIST

If the participantId does not exist in the contacts, returns NOT_A_CONTACT

If the host account is not an administrator, returns INSUFFICIENT_PERMISSIONS

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us'
participantIdContactId | ContactId[]'000000000000@c.us'

Returns​

Promise<boolean>


archiveChat​

β–Έ archiveChat(id, archive): Promise<boolean>

Parameters​

NameTypeDescription
idChatIdThe id of the conversation
archivebooleanboolean true => archive, false => unarchive

Returns​

Promise<boolean>

boolean true: worked, false: didnt work (probably already in desired state)


autoReject​

β–Έ autoReject(message?): Promise<boolean>

Automatically reject calls on the host account device. Please note that the device that is calling you will continue to ring.

Update: Due to the nature of MD, the host account will continue ringing.

Parameters​

NameTypeDescription
message?stringoptional message to send to the calling account when their call is detected and rejected

Returns​

Promise<boolean>


awaitMessages​

β–Έ awaitMessages(c, filter, options?): Promise<Collection<string, Message>>

[FROM DISCORDJS] Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.

Example

// Await !vote messages
const filter = m => m.body.startsWith('!vote');
// Errors: ['time'] treats ending because of the time limit as an error
channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
.then(collected => console.log(collected.size))
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));

Parameters​

NameTypeDescription
cChatId | Message | ChatThe Mesasge/Chat or Chat Id to base this message colletor on
filterCollectorFilter<[Message]>The filter function to use
options?AwaitMessagesOptionsOptional options to pass to the internal collector

Returns​

Promise<Collection<string, Message>>


checkNumberStatus​

β–Έ checkNumberStatus(contactId): Promise<NumberCheck>

Checks if a number is a valid WA number

Parameters​

NameType
contactIdContactId

Returns​

Promise<NumberCheck>


checkReadReceipts
insiders
​

β–Έ checkReadReceipts(contactId): Promise<string | boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Check if a recipient has read receipts on.

This will only work if you have chats sent back and forth between you and the contact 1-1.

Parameters​

NameTypeDescription
contactIdContactIdThe Id of the contact with which you have an existing conversation with messages already.

Returns​

Promise<string | boolean>

Promise<string | boolean> true or false or a string with an explaintaion of why it wasn't able to determine the read receipts.


clearAllChats​

β–Έ clearAllChats(ts?): Promise<boolean>

Clears all chats of all messages. This does not delete chats. Please be careful with this as it will remove all messages from whatsapp web and the host device. This feature is great for privacy focussed bots.

Parameters​

NameTypeDescription
ts?numbernumber A chat that has had a message after ts (epoch timestamp) will not be cleared.

Returns​

Promise<boolean>


clearChat​

β–Έ clearChat(chatId): Promise<boolean>

Delete all messages from the chat.

Parameters​

NameType
chatIdChatId

Returns​

Promise<boolean>

boolean


contactBlock​

β–Έ contactBlock(id): Promise<boolean>

Block contact

Parameters​

NameTypeDescription
idContactId'000000000000@c.us'

Returns​

Promise<boolean>


contactUnblock​

β–Έ contactUnblock(id): Promise<boolean>

Unblock contact

Parameters​

NameTypeDescription
idContactId'000000000000@c.us'

Returns​

Promise<boolean>


createCommunity
insiders
​

β–Έ createCommunity(communityName, communitySubject, icon, existingGroups?, newGroups?): Promise\`${number}@g.us\`\

πŸ…May require insiders license

Use this link to get the correct license.

Create a new community

Parameters​

NameTypeDefault valueDescription
communityNamestringundefinedThe community name
communitySubjectstringundefined-
iconDataURLundefinedDataURL of a 1:1 ratio jpeg for the community icon
existingGroupsGroupChatId[][]An array of existing group IDs, that are not already part of a community, to add to this new community.
newGroups?NewCommunityGroup[]undefinedAn array of new group objects that

Returns​

Promise\`${number}@g.us\`\


createGroup​

β–Έ createGroup(groupName, contacts): Promise<GroupChatCreationResponse>

Create a group and add contacts to it

Parameters​

NameTypeDescription
groupNamestringgroup name: 'New group'
contactsContactId | ContactId[]-

Returns​

Promise<GroupChatCreationResponse>


createLabel
insiders
​

β–Έ createLabel(label): Promise<string | boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Adds label from chat, message or contact. Only for business accounts.

Parameters​

NameType
labelstring

Returns​

Promise<string | boolean>

false if something went wrong, or the id (usually a number as a string) of the new label (for example "58")


createMessageCollector​

β–Έ createMessageCollector(c, filter, options): MessageCollector

Returns a new message collector for the chat which is related to the first parameter c

Parameters​

NameTypeDescription
cChatId | Message | ChatThe Mesasge/Chat or Chat Id to base this message colletor on
filterCollectorFilter<[Message]>A function that consumes a [Message] and returns a boolean which determines whether or not the message shall be collected.
optionsCollectorOptionsThe options for the collector. For example, how long the collector shall run for, how many messages it should collect, how long between messages before timing out, etc.

Returns​

MessageCollector


createNewProduct
insiders
​

β–Έ createNewProduct(name, price, currency, images, description, url?, internalId?, isHidden?): Promise<Product>

πŸ…May require insiders license

Use this link to get the correct license.

Add a product to your catalog

Parameters​

NameTypeDescription
namestringThe name of the product
pricenumberThe price of the product
currencystringThe 3-letter currenct code for the product
imagesstring[]An array of dataurl or base64 strings of product images, the first image will be used as the main image. At least one image is required.
descriptionstringoptional, the description of the product
url?stringThe url of the product for more information
internalId?stringThe internal/backoffice id of the product
isHidden?booleanWhether or not the product is shown publicly in your catalog

Returns​

Promise<Product>

product object


cutChatCache​

β–Έ cutChatCache(): Promise<{ after: { chats: number ; msgs: number } ; before: { chats: number ; msgs: number } }>

This simple function halves the amount of chats in your session message cache. This does not delete messages off your phone. If over a day you've processed 4000 messages this will possibly result in 4000 messages being present in your session. Calling this method will cut the message cache as much as possible, reducing the memory usage of your process. You should use this in conjunction with getAmountOfLoadedMessages to intelligently control the session message cache.

Returns​

Promise<{ after: { chats: number ; msgs: number } ; before: { chats: number ; msgs: number } }>


cutMsgCache​

β–Έ cutMsgCache(): Promise<number>

This simple function halves the amount of messages in your session message cache. This does not delete messages off your phone. If over a day you've processed 4000 messages this will possibly result in 4000 messages being present in your session. Calling this method will cut the message cache to 2000 messages, therefore reducing the memory usage of your process. You should use this in conjunction with getAmountOfLoadedMessages to intelligently control the session message cache.

Returns​

Promise<number>


darkMode​

β–Έ darkMode(activate): Promise<boolean>

Start dark mode [NOW GENERALLY AVAILABLE]

Parameters​

NameTypeDescription
activatebooleantrue to activate dark mode, false to deactivate

Returns​

Promise<boolean>


decryptMedia​

β–Έ decryptMedia(message): Promise<DataURL>

Decrypts a media message.

Parameters​

NameTypeDescription
messageMessageId | MessageThis can be the serialized MessageId or the whole Message object. It is advised to just use the serialized message ID.

Returns​

Promise<DataURL>

Promise<[[DataURL]]>


deleteAllStatus​

β–Έ deleteAllStatus(): Promise<boolean>

Deprecated

Alias for deleteStory

Returns​

Promise<boolean>


deleteAllStories
restricted
​

β–Έ deleteAllStories(): Promise<boolean>

πŸ…May require restricted license

Use this link to get the correct license.

Deletes all your existing stories.

Returns​

Promise<boolean>

boolean. True if it worked.


deleteChat​

β–Έ deleteChat(chatId): Promise<boolean>

Delete the conversation from your WA

Parameters​

NameType
chatIdChatId

Returns​

Promise<boolean>

boolean


deleteMessage​

β–Έ deleteMessage(chatId, messageId, onlyLocal?): Promise<void>

Deletes message of given message id

Parameters​

NameTypeDefault valueDescription
chatIdChatIdundefinedThe chat id from which to delete the message.
messageIdMessageId | MessageId[]undefinedThe specific message id of the message to be deleted
onlyLocalbooleanfalseIf it should only delete locally (message remains on the other recipienct's phone). Defaults to false.

Returns​

Promise<void>

nothing


deleteStaleChats​

β–Έ deleteStaleChats(startingFrom?): Promise<boolean>

Deletes chats from a certain index (default 1000). E.g if this startingFrom param is 100 then all chats from index 100 onwards will be deleted.

Parameters​

NameTypeDescription
startingFrom?numberthe chat index to start from. Please do not set this to anything less than 10 @default: 1000

Returns​

Promise<boolean>


deleteStatus​

β–Έ deleteStatus(statusesToDelete): Promise<boolean>

Deprecated

Alias for deleteStory

Parameters​

NameType
statusesToDeletestring | string[]

Returns​

Promise<boolean>


deleteStory
restricted
​

β–Έ deleteStory(statusesToDelete): Promise<boolean>

πŸ…May require restricted license

Use this link to get the correct license.

Consumes a list of id strings of stories to delete.

Parameters​

NameTypeDescription
statusesToDeletestring | string[]string [] | string an array of ids of stories to delete.

Returns​

Promise<boolean>

boolean. True if it worked.


demoteParticipant​

β–Έ demoteParticipant(groupId, participantId): Promise<boolean>

Demote Admin of Group

If not a group chat, returns NOT_A_GROUP_CHAT.

If the chat does not exist, returns GROUP_DOES_NOT_EXIST

If the participantId does not exist in the group chat, returns NOT_A_PARTICIPANT

If the host account is not an administrator, returns INSUFFICIENT_PERMISSIONS

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us'
participantIdContactId | ContactId[]'000000000000@c.us'

Returns​

Promise<boolean>


download​

β–Έ download(url, optionsOverride?): Promise<DataURL>

A convinience method to download the DataURL of a file

Parameters​

NameTypeDescription
urlstringThe url
optionsOverrideanyYou can use this to override the axios request config

Returns​

Promise<DataURL>

Promise<DataURL>


downloadFileWithCredentials​

β–Έ downloadFileWithCredentials(url): Promise<Base64>

Download via the browsers authenticated session via URL.

Parameters​

NameType
urlstring

Returns​

Promise<Base64>

base64 string (non-data url)


downloadProfilePicFromMessage​

β–Έ downloadProfilePicFromMessage(message): Promise<Base64>

Download profile pics from the message object.

 const filename = `profilepic_${message.from}.jpeg`;
const data = await client.downloadProfilePicFromMessage(message);
const dataUri = `data:image/jpeg;base64,${data}`;
fs.writeFile(filename, mData, 'base64', function(err) {
if (err) {
return console.log(err);
}
console.log('The file was saved!');
});

Parameters​

NameType
messageMessage

Returns​

Promise<Base64>


editProduct
insiders
​

β–Έ editProduct(productId, name?, price?, currency?, images?, description?, url?, internalId?, isHidden?): Promise<Product>

πŸ…May require insiders license

Use this link to get the correct license.

Edit a product in your catalog

Parameters​

NameTypeDescription
productIdstringThe catalog ID of the product
name?stringThe name of the product
price?numberThe price of the product
currency?stringThe 3-letter currenct code for the product
images?DataURL[]An array of dataurl or base64 strings of product images, the first image will be used as the main image. At least one image is required.
description?stringoptional, the description of the product
url?stringThe url of the product for more information
internalId?stringThe internal/backoffice id of the product
isHidden?booleanWhether or not the product is shown publicly in your catalog

Returns​

Promise<Product>

product object


emitUnreadMessages​

β–Έ emitUnreadMessages(): Promise<MessageId[]>

Fires all unread messages to the onMessage listener. Make sure to call this AFTER setting your listeners.

Returns​

Promise<MessageId[]>

array of message IDs


forceRefocus​

β–Έ forceRefocus(): Promise<boolean>

This is a convinient method to click the Use Here button in the WA web session.

Use this when STATE is CONFLICT. You can read more about managing state here:

Detecting Logouts

Returns​

Promise<boolean>


forceStaleMediaUpdate
insiders
​

β–Έ forceStaleMediaUpdate(messageId): Promise<false | Message>

πŸ…May require insiders license

Use this link to get the correct license.

If a file is old enough, it will 404 if you try to decrypt it. This will allow you to force the host account to re upload the file and return a decryptable message.

if you run this without a valid insiders key, it will return false and cause an error upon decryption.

Parameters​

NameType
messageIdMessageId

Returns​

Promise<false | Message>

Message OR false


forceUpdateConnectionState​

β–Έ forceUpdateConnectionState(): Promise<STATE>

Forces the session to update the connection state. This will take a few seconds to determine the 'correct' state.

Returns​

Promise<STATE>

updated connection state


forceUpdateLiveLocation​

β–Έ forceUpdateLiveLocation(chatId): Promise<boolean | LiveLocationChangedEvent[]>

A list of participants in the chat who have their live location on. If the chat does not exist, or the chat does not have any contacts actively sharing their live locations, it will return false. If it's a chat with a single contact, there will be only 1 value in the array if the contact has their livelocation on. Please note. This should only be called once every 30 or so seconds. This forces the phone to grab the latest live location data for the number. This can be used in conjunction with onLiveLocation (this will trigger onLiveLocation).

Parameters​

NameTypeDescription
chatIdChatIdstring Id of the chat you want to force the phone to get the livelocation data for.

Returns​

Promise<boolean | LiveLocationChangedEvent[]>

Promise<LiveLocationChangedEvent []> | boolean


forwardMessages​

β–Έ forwardMessages(to, messages, skipMyMessages): Promise<boolean | MessageId[]>

Forward an array of messages to a specific chat using the message ids or Objects

Parameters​

NameTypeDescription
toChatId'000000000000@c.us'
messagesMessageId | MessageId[]this can be any mixture of message ids or message objects
skipMyMessagesbooleanThis indicates whether or not to skip your own messages from the array

Returns​

Promise<boolean | MessageId[]>


gc​

β–Έ gc(): Promise<void>

It calls the JavaScript garbage collector

Returns​

Promise<void>

Nothing.


getAllChatIds​

β–Έ getAllChatIds(): Promise<ChatId[]>

retrieves all Chat Ids

Returns​

Promise<ChatId[]>

array of [ChatId]


getAllChats​

β–Έ getAllChats(withNewMessageOnly?): Promise<Chat[]>

Retrieves all chats

Parameters​

NameTypeDefault value
withNewMessageOnlybooleanfalse

Returns​

Promise<Chat[]>

array of [Chat]


getAllChatsWithMessages​

β–Έ getAllChatsWithMessages(withNewMessageOnly?): Promise<Chat[]>

Deprecated

Retrieves all chats with messages

Please use getAllUnreadMessages instead of this to see all messages indicated by the green dots in the chat.

Parameters​

NameTypeDefault value
withNewMessageOnlybooleanfalse

Returns​

Promise<Chat[]>

array of [Chat]


getAllContacts​

β–Έ getAllContacts(): Promise<Contact[]>

Retrieves all contacts

Returns​

Promise<Contact[]>

array of [Contact]


getAllGroups​

β–Έ getAllGroups(withNewMessagesOnly?): Promise<Chat[]>

Retrieve all groups

Parameters​

NameTypeDefault value
withNewMessagesOnlybooleanfalse

Returns​

Promise<Chat[]>

array of groups


getAllLabels​

β–Έ getAllLabels(): Promise<Label[]>

Returns all labels and the corresponding tagged items.

Returns​

Promise<Label[]>


getAllMessagesInChat​

β–Έ getAllMessagesInChat(chatId, includeMe, includeNotifications): Promise<Message[]>

Retrieves all Messages in a chat that have been loaded within the WA web instance.

This does not load every single message in the chat history.

Parameters​

NameType
chatIdChatId
includeMeboolean
includeNotificationsboolean

Returns​

Promise<Message[]>

Message[]


getAllNewMessages​

β–Έ getAllNewMessages(): Promise<Message[]>

Retrieves all new Messages. where isNewMsg==true

Returns​

Promise<Message[]>

list of messages


getAllUnreadMessages​

β–Έ getAllUnreadMessages(): Promise<Message[]>

Retrieves all unread Messages. where ack==-1

Returns​

Promise<Message[]>

list of messages


getAmountOfLoadedMessages​

β–Έ getAmountOfLoadedMessages(): Promise<number>

Easily get the amount of messages loaded up in the session. This will allow you to determine when to clear chats/cache.

Returns​

Promise<number>


getBatteryLevel​

β–Έ getBatteryLevel(): Promise<number>

Retrieves Battery Level

Returns​

Promise<number>

Number


getBlockedIds​

β–Έ getBlockedIds(): Promise<ChatId[]>

retrieves an array of IDs of accounts blocked by the host account.

Returns​

Promise<ChatId[]>

Promise<ChatId[]>


getBusinessProfilesProducts​

β–Έ getBusinessProfilesProducts(id): Promise<any>

Find any product listings of the given number. Use this to query a catalog

Parameters​

NameTypeDescription
idContactIdid of buseinss profile (i.e the number with @c.us)

Returns​

Promise<any>

None


getChat​

β–Έ getChat(contactId): Promise<Chat>

Retrieves chat object of given contact id

Parameters​

NameType
contactIdContactId

Returns​

Promise<Chat>

contact detial as promise


getChatById​

β–Έ getChatById(contactId): Promise<Chat>

Retrieves chat object of given contact id

Parameters​

NameType
contactIdContactId

Returns​

Promise<Chat>

contact detial as promise


getChatWithNonContacts​

β–Έ getChatWithNonContacts(): Promise<Contact[]>

Returns a list of contact with whom the host number has an existing chat who are also not contacts.

Returns​

Promise<Contact[]>


getChatsByLabel​

β–Έ getChatsByLabel(label): Promise<Chat[]>

Get an array of chats that match the label parameter. For example, if you want to get an array of chat objects that have the label "New customer".

This method is case insenstive and only works on business host accounts.

Label

The label name

Parameters​

NameType
labelstring

Returns​

Promise<Chat[]>


getCommonGroups
insiders
​

β–Έ getCommonGroups(contactId): Promise<{ id: string ; title: string }[]>

πŸ…May require insiders license

Use this link to get the correct license.

Retrieves the groups that you have in common with a contact

Parameters​

NameType
contactIdContactId

Returns​

Promise<{ id: string ; title: string }[]>

Promise returning an array of common groups { id:string, title:string }


getConfig​

β–Έ getConfig(): ConfigObject

Get the config which was used to set up the client. Sensitive details (like devTools username and password, and browserWSEndpoint) are scrubbed

Returns​

ConfigObject

SessionInfo


getConnectionState​

β–Έ getConnectionState(): Promise<STATE>

Returns the connection state

Returns​

Promise<STATE>


getContact​

β–Έ getContact(contactId): Promise<Contact>

Retrieves contact detail object of given contact id

Parameters​

NameType
contactIdContactId

Returns​

Promise<Contact>

contact detial as promise


getEventSignature​

β–Έ getEventSignature(simpleListener?): string

Parameters​

NameType
simpleListener?SimpleListener

Returns​

string


getFeatures​

β–Έ getFeatures(): Promise<any>

Returns an object with properties of internal features and boolean values that represent if the respective feature is enabled or not.

Returns​

Promise<any>


getGeneratedUserAgent​

β–Έ getGeneratedUserAgent(userA?): Promise<string>

Get the generated user agent, this is so you can send it to the decryption module.

Parameters​

NameType
userA?string

Returns​

Promise<string>

String useragent of wa-web session


getGroupAdmins​

β–Έ getGroupAdmins(groupId): Promise<ContactId[]>

Get Admins of a Group

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us'

Returns​

Promise<ContactId[]>


getGroupInfo​

β–Έ getGroupInfo(groupId): Promise<any>

Returns the title and description of a given group id.

Parameters​

NameTypeDescription
groupIdGroupChatIdgroup id

Returns​

Promise<any>


β–Έ getGroupInviteLink(chatId): Promise<string>

Retrieves an invite link for a group chat. returns false if chat is not a group.

Parameters​

NameType
chatIdChatId

Returns​

Promise<string>

Promise<string>


getGroupMembers​

β–Έ getGroupMembers(groupId): Promise<Contact[]>

Returns group members [Contact] objects

Parameters​

NameType
groupIdGroupChatId

Returns​

Promise<Contact[]>


getGroupMembersId​

β–Έ getGroupMembersId(groupId): Promise<ContactId[]>

Retrieves group members as [Id] objects

Parameters​

NameTypeDescription
groupIdGroupChatIdgroup id

Returns​

Promise<ContactId[]>


getHostNumber​

β–Έ getHostNumber(): Promise<string>

Retrieves the host device number. Use this number when registering for a license key

Returns​

Promise<string>

Number


getIndicatedNewMessages​

β–Έ getIndicatedNewMessages(): Promise<Message[]>

Retrieves all unread Messages as indicated by the red dots in WA web. This returns an array of objects and are structured like so:

[{
"id": "000000000000@g.us", //the id of the chat
"indicatedNewMessages": [] //array of messages, not including any messages by the host phone
}]

Returns​

Promise<Message[]>

list of messages


getInstanceId​

β–Έ getInstanceId(): string

Get the INSTANCE_ID of the current session

Returns​

string


getIsPlugged​

β–Έ getIsPlugged(): Promise<boolean>

Retrieves whether or not phone is plugged in (i.e on charge)

Returns​

Promise<boolean>

Number


β–Έ getIssueLink(): Promise<string>

Generate a pre-filled github issue link to easily report a bug

Returns​

Promise<string>


getKickedGroups​

β–Έ getKickedGroups(): Promise<GroupChatId[]>

Returns an array of group ids where the host account has been kicked

Returns​

Promise<GroupChatId[]>


getLastMsgTimestamps​

β–Έ getLastMsgTimestamps(): Promise<{ id: ChatId ; t: number }[]>

Get an array of chatIds with their respective last message's timestamp.

This is useful for determining what chats are old/stale and need to be deleted.

Returns​

Promise<{ id: ChatId ; t: number }[]>


getLastSeen​

β–Έ getLastSeen(chatId): Promise<number | boolean>

Retrieves the epoch timestamp of the time the contact was last seen. This will not work if:

  1. They have set it so you cannot see their last seen via privacy settings.
  2. You do not have an existing chat with the contact.
  3. The chatId is for a group In both of those instances this method will return undefined.

Parameters​

NameTypeDescription
chatIdChatIdThe id of the chat.

Returns​

Promise<number | boolean>

number timestamp when chat was last online or undefined.


β–Έ getLicenseLink(params?): Promise<string>

Generate a license link

Parameters​

NameType
params?string

Returns​

Promise<string>


getLicenseType​

β–Έ getLicenseType(): Promise<false | LicenseType>

Returns the the type of license key used by the session.

Returns​

Promise<false | LicenseType>


getListenerQueues​

β–Έ getListenerQueues(): Object

If you have set onAnyMessage or onMessage with the second parameter (PQueue options) then you may want to inspect their respective PQueue's.

Returns​

Object

NameType
onAckdefault<default, DefaultAddOptions>
onAddedToGroupdefault<default, DefaultAddOptions>
onAnyMessagedefault<default, DefaultAddOptions>
onBatterydefault<default, DefaultAddOptions>
onBroadcastdefault<default, DefaultAddOptions>
onButtondefault<default, DefaultAddOptions>
onCallStatedefault<default, DefaultAddOptions>
onChatDeleteddefault<default, DefaultAddOptions>
onChatOpeneddefault<default, DefaultAddOptions>
onChatStatedefault<default, DefaultAddOptions>
onContactAddeddefault<default, DefaultAddOptions>
onGlobalParticipantsChangeddefault<default, DefaultAddOptions>
onGroupChangedefault<default, DefaultAddOptions>
onIncomingCalldefault<default, DefaultAddOptions>
onLabeldefault<default, DefaultAddOptions>
onLogoutdefault<default, DefaultAddOptions>
onMessagedefault<default, DefaultAddOptions>
onMessageDeleteddefault<default, DefaultAddOptions>
onNewProductdefault<default, DefaultAddOptions>
onOrderdefault<default, DefaultAddOptions>
onPluggeddefault<default, DefaultAddOptions>
onPollVotedefault<default, DefaultAddOptions>
onReactiondefault<default, DefaultAddOptions>
onRemovedFromGroupdefault<default, DefaultAddOptions>
onStateChangeddefault<default, DefaultAddOptions>
onStorydefault<default, DefaultAddOptions>

getMe​

β–Έ getMe(): Promise<any>

Returns an object with all of your host device details

Returns​

Promise<any>


getMessageById​

β–Έ getMessageById(messageId): Promise<Message>

Retrieves message object of given message id

Parameters​

NameType
messageIdMessageId

Returns​

Promise<Message>

message object


getMessageInfo
insiders
​

β–Έ getMessageInfo(messageId): Promise<MessageInfo>

πŸ…May require insiders license

Use this link to get the correct license.

Get the detailed message info for a group message sent out by the host account.

Parameters​

NameTypeDescription
messageIdMessageIdThe message Id

Returns​

Promise<MessageInfo>


getMessageReaders​

β–Έ getMessageReaders(messageId): Promise<Contact[]>

Returns an array of contacts that have read the message. If the message does not exist, it will return an empty array. If the host account has disabled read receipts this may not work! Each of these contact objects have a property t which represents the time at which that contact read the message.

Parameters​

NameTypeDescription
messageIdMessageIdThe message id

Returns​

Promise<Contact[]>


getMyLastMessage​

β–Έ getMyLastMessage(chatId?): Promise<Message>

Retrieves the last message sent by the host account in any given chat or globally.

Parameters​

NameTypeDescription
chatId?ChatIdThis is optional. If no chat Id is set then the last message sent by the host account will be returned.

Returns​

Promise<Message>

message object or undefined if the host account's last message could not be found.


getMyStatusArray​

β–Έ getMyStatusArray(): Promise<Message[]>

Deprecated

Alias for deleteStory

Returns​

Promise<Message[]>


getMyStoryArray
restricted
​

β–Έ getMyStoryArray(): Promise<Message[]>

πŸ…May require restricted license

Use this link to get the correct license.

Retrieves all existing stories.

Only works with a Story License Key

Returns​

Promise<Message[]>


getOrder
insiders
​

β–Έ getOrder(id): Promise<Order>

πŸ…May require insiders license

Use this link to get the correct license.

Retrieves an order object

Parameters​

NameType
idstring | MessageId

Returns​

Promise<Order>

order object


getPage​

β–Έ getPage(): Page

Returns​

Page


getPollData​

β–Έ getPollData(messageId): Promise<PollData>

Returns poll data including results and votes.

Parameters​

NameTypeDescription
messageIdMessageIdThe message id of the Poll

Returns​

Promise<PollData>


getProcessStats​

β–Έ getProcessStats(): Promise<any>

Get the stats of the current process and the corresponding browser process.

Returns​

Promise<any>


getProfilePicFromServer​

β–Έ getProfilePicFromServer(chatId): Promise<string>

Retrieves chat picture

Parameters​

NameType
chatIdChatId

Returns​

Promise<string>

Url of the chat picture or undefined if there is no picture for the chat.


getSessionId​

β–Έ getSessionId(): string

Returns​

string


getSessionInfo​

β–Έ getSessionInfo(): SessionInfo

Get the session info

Returns​

SessionInfo

SessionInfo


getSingleProperty​

β–Έ getSingleProperty(namespace, id, property): Promise<any>

This allows you to get a single property of a single object from the session. This limints the amouunt of data you need to sift through, reduces congestion between your process and the session and the flexibility to build your own specific getters.

Example - get message read state (ack):

const ack  = await client.getSingleProperty('Msg',"true_12345678912@c.us_9C4D0965EA5C09D591334AB6BDB07FEB",'ack')

Parameters​

NameTypeDescription
namespacenamespace
idstringid of the object to get from the specific namespace
propertystringthe single property key to get from the object.

Returns​

Promise<any>

any If the property or the id cannot be found, it will return a 404


getSnapshot​

β–Έ getSnapshot(chatId?): Promise<DataURL>

Returns a PNG DataURL screenshot of the session

Parameters​

NameType
chatId?ChatId

Returns​

Promise<DataURL>

Promise<DataURL>


getStarredMessages​

β–Έ getStarredMessages(chatId?): Promise<Message[]>

Retrieves the starred messages in a given chat

Parameters​

NameTypeDescription
chatId?ChatIdChat ID to filter starred messages by

Returns​

Promise<Message[]>

message object


getStatus​

β–Έ getStatus(contactId): Promise<{ id: string ; status: string }>

Get the status of a contact

Parameters​

NameTypeDescription
contactIdContactId{string} to '000000000000@c.us' returns: {id: string,status: string}

Returns​

Promise<{ id: string ; status: string }>


getStickerDecryptable​

β–Έ getStickerDecryptable(messageId): Promise<false | Message>

Deprecated

Retrieves a message object which results in a valid sticker instead of a blank one. This also works with animated stickers.

If you run this without a valid insiders key, it will return false and cause an error upon decryption.

Parameters​

NameTypeDescription
messageIdMessageIdThe message ID message.id

Returns​

Promise<false | Message>

message object OR false


getStoryViewers
restricted
​

β–Έ getStoryViewers(id?): Promise<ContactId[] | { [k: MessageId]: ContactId[]; }>

πŸ…May require restricted license

Use this link to get the correct license.

Retrieves an array of user ids that have 'read' your story.

Parameters​

NameTypeDescription
id?stringstring The id of the story

Returns​

Promise<ContactId[] | { [k: MessageId]: ContactId[]; }>


getTunnelCode​

β–Έ getTunnelCode(): Promise<string>

The EASY API uses this string to secure a subdomain on the openwa public tunnel service.

Returns​

Promise<string>


getUnreadMessages​

β–Έ getUnreadMessages(includeMe, includeNotifications, use_unread_count): Promise<SingleChat & { messages: Message[] } & GroupChat & { messages: Message[] }>

Retrieves all undread Messages

Parameters​

NameType
includeMeboolean
includeNotificationsboolean
use_unread_countboolean

Returns​

Promise<SingleChat & { messages: Message[] } & GroupChat & { messages: Message[] }>

any


getUnsentMessages​

β–Έ getUnsentMessages(): Promise<Message[]>

Retreive an array of messages that are not yet sent to the recipient via the host account device (i.e no ticks)

Returns​

Promise<Message[]>


getVCards​

β–Έ getVCards(msgId): Promise<string[]>

Extracts vcards from a message.This works on messages of typ vcard or multi_vcard

Parameters​

NameTypeDescription
msgIdMessageIdstring id of the message to extract the vcards from

Returns​

Promise<string[]>

[vcard]

[
{
displayName:"Contact name",
vcard: "loong vcard string"
}
]

or false if no valid vcards found.

Please use vcf to convert a vcard string into a json object


getWAVersion​

β–Έ getWAVersion(): Promise<string>

Returns​

Promise<string>


ghostForward​

β–Έ ghostForward(to, messageId): Promise<boolean | MessageId>

Ghost forwarding is like a normal forward but as if it were sent from the host phone [i.e it doesn't show up as forwarded.] Any potential abuse of this method will see it become paywalled.

Parameters​

NameType
toChatId
messageIdMessageId

Returns​

Promise<boolean | MessageId>

Promise<MessageId | boolean>


healthCheck​

β–Έ healthCheck(): Promise<HealthCheck>

Runs a health check to help you determine if/when is an appropiate time to restart/refresh the session.

Returns​

Promise<HealthCheck>


iAmAdmin​

β–Έ iAmAdmin(): Promise<GroupChatId[]>

Returns an array of group ids where the host account is admin

Returns​

Promise<GroupChatId[]>


inviteInfo​

β–Έ inviteInfo(link): Promise<any>

Get the details of a group through the invite link

Parameters​

NameTypeDescription
linkstringThis can be an invite link or invite code

Returns​

Promise<any>


isChatMuted​

β–Έ isChatMuted(chatId): Promise<boolean>

Checks if a chat is muted

Parameters​

NameTypeDescription
chatIdChatIdThe id of the chat you want to check

Returns​

Promise<boolean>

boolean. false if the chat does not exist.


isChatOnline​

β–Έ isChatOnline(chatId): Promise<string | boolean>

Checks if a chat contact is online. Not entirely sure if this works with groups.

It will return true if the chat is online, false if the chat is offline, PRIVATE if the privacy settings of the contact do not allow you to see their status and NO_CHAT if you do not currently have a chat with that contact.

Parameters​

NameTypeDescription
chatIdChatIdchat id: xxxxx@c.us

Returns​

Promise<string | boolean>


isConnected​

β–Έ isConnected(): Promise<boolean>

Retrieves if the phone is online. Please note that this may not be real time.

Returns​

Promise<boolean>

Boolean


isGroupIdUnsafe
insiders
​

β–Έ isGroupIdUnsafe(groupChatId): Promise<string | boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Checks whether or not the group id provided is known to be unsafe by the contributors of the library.

Parameters​

NameTypeDescription
groupChatIdGroupChatIdThe group chat you want to deteremine is unsafe

Returns​

Promise<string | boolean>

Promise <boolean | string> This will either return a boolean indiciating whether this group chat id is considered unsafe or an error message as a string


isPhoneDisconnected​

β–Έ isPhoneDisconnected(): Promise<boolean>

Check if the "Phone not Cconnected" message is showing in the browser. If it is showing, then this will return true.

Returns​

Promise<boolean>

boolean


β–Έ joinGroupViaLink(link, returnChatObj?): Promise<string | number | boolean | Chat>

Joins a group via the invite link, code, or message

Parameters​

NameTypeDescription
linkstringThis param is the string which includes the invite link or code. The following work: - Follow this link to join my WA group: https://chat.whatsapp.com/DHTGJUfFJAV9MxOpZO1fBZ - https://chat.whatsapp.com/DHTGJUfFJAV9MxOpZO1fBZ - DHTGJUfFJAV9MxOpZO1fBZ If you have been removed from the group previously, it will return 401
returnChatObj?booleanboolean When this is set to true and if the group was joined successfully, it will return a serialzed Chat object which includes group information and metadata. This is useful when you want to immediately do something with group metadata.

Returns​

Promise<string | number | boolean | Chat>

Promise<string | boolean | number> Either false if it didn't work, or the group id.


kill​

β–Έ kill(reason?): Promise<boolean>

Shuts down the page and browser

Parameters​

NameTypeDefault value
reasonstring"MANUALLY_KILLED"

Returns​

Promise<boolean>

true


leaveGroup​

β–Έ leaveGroup(groupId): Promise<boolean>

Removes the host device from the group

Parameters​

NameTypeDescription
groupIdGroupChatIdgroup id

Returns​

Promise<boolean>


listWebhooks​

β–Έ listWebhooks(): Promise<Webhook[]>

Retreives an array of webhook objects

Returns​

Promise<Webhook[]>


loadAllEarlierMessages​

β–Έ loadAllEarlierMessages(contactId): Promise<Message[]>

Load all messages in chat object from server.

Parameters​

NameType
contactIdContactId

Returns​

Promise<Message[]>

Message[]


loadAndGetAllMessagesInChat​

β–Έ loadAndGetAllMessagesInChat(chatId, includeMe, includeNotifications): Promise<Message[]>

loads and Retrieves all Messages in a chat

Parameters​

NameType
chatIdChatId
includeMeboolean
includeNotificationsboolean

Returns​

Promise<Message[]>

any


loadEarlierMessages​

β–Έ loadEarlierMessages(contactId): Promise<Message[]>

Load more messages in chat object from server. Use this in a while loop. This should return up to 50 messages at a time

Parameters​

NameType
contactIdContactId

Returns​

Promise<Message[]>

Message []


loadEarlierMessagesTillDate​

β–Έ loadEarlierMessagesTillDate(contactId, timestamp): Promise<Message[]>

Load all messages until a given timestamp in chat object from server.

Parameters​

NameTypeDescription
contactIdContactId
timestampnumberin seconds

Returns​

Promise<Message[]>

Message[]


logger​

β–Έ logger(): any

Grab the logger for this session/process

Returns​

any


logout​

β–Έ logout(preserveSessionData?): Promise<boolean>

Logs out from the session.

Parameters​

NameTypeDefault valueDescription
preserveSessionDatabooleanfalseskip session.data.json file invalidation Please be careful when using this as it can exit the whole process depending on your config

Returns​

Promise<boolean>


markAllRead​

β–Έ markAllRead(): Promise<boolean>

Runs sendSeen on all chats

Returns​

Promise<boolean>


markAsUnread​

β–Έ markAsUnread(chatId): Promise<boolean>

Sets a chat status to unread. May be useful to get host's attention

Parameters​

NameTypeDescription
chatIdChatIdchat id: xxxxx@c.us

Returns​

Promise<boolean>


metrics​

β–Έ metrics(): Promise<any>

Returns some metrics of the session/page.

Returns​

Promise<any>

Promise<any>


middleware​

β–Έ middleware(useSessionIdInPath?, PORT?): (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => Promise<any>

This exposes a simple express middlware that will allow users to quickly boot up an api based off this client. Checkout demo/index.ts for an example How to use the middleware:


import { create } from '@open-wa/wa-automate';
const express = require('express')
const app = express()
app.use(express.json())
const PORT = 8082;

function start(client){
app.use(client.middleware()); //or client.middleware(true) if you require the session id to be part of the path (so localhost:8082/sendText beccomes localhost:8082/sessionId/sendText)
app.listen(PORT, function () {
console.log(`\nβ€’ Listening on port ${PORT}!`);
});
...
}

create({
sessionId:'session1'
}).then(start)

All requests need to be POST requests. You use the API the same way you would with client. The method can be the path or the method param in the post body. The arguments for the method should be properly ordered in the args array in the JSON post body.

Example:

  await client.sendText('4477777777777@c.us','test')
//returns "true_4477777777777@c.us_3EB0645E623D91006252"

as a request with a path:

const axios = require('axios').default;
axios.post('localhost:8082/sendText', {
args: [
"4477777777777@c.us",
"test"
]
})

or as a request without a path:

const axios = require('axios').default;
axios.post('localhost:8082', {
method:'sendText',
args: [
"4477777777777@c.us",
"test"
]
})

As of 1.9.69, you can also send the argyments as an object with the keys mirroring the paramater names of the relative client functions

Example:

const axios = require('axios').default;
axios.post('localhost:8082', {
method:'sendText',
args: {
"to":"4477777777777@c.us",
"content":"test"
}
})

Parameters​

NameTypeDefault valueDescription
useSessionIdInPathbooleanfalseboolean Set this to true if you want to keep each session in it's own path. For example, if you have a session with id host if you set useSessionIdInPath to true, then all requests will need to be prefixed with the path host. E.g localhost:8082/sendText becomes localhost:8082/host/sendText
PORT?numberundefined-

Returns​

fn

β–Έ (req, res, next): Promise<any>

Parameters​
NameType
reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
resResponse<any, Record<string, any>>
nextNextFunction
Returns​

Promise<any>


muteChat
insiders
​

β–Έ muteChat(chatId, muteDuration): Promise<string | number | boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Mutes a conversation for a given duration. If already muted, this will update the muted duration. Mute durations are relative from when the method is called.

Parameters​

NameTypeDescription
chatIdChatIdThe id of the conversation you want to mute
muteDurationChatMuteDurationChatMuteDuration enum of the time you want this chat to be muted for.

Returns​

Promise<string | number | boolean>

boolean true: worked or error code or message


onNewProduct
insiders
​

β–Έ onNewProduct(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Listens to new orders. Only works on business accounts

Parameters​

NameType
fn(product: Product) => void

Returns​

Promise<boolean | Listener>


onOrder
insiders
​

β–Έ onOrder(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Listens to new orders. Only works on business accounts

Parameters​

NameType
fn(order: Order) => void

Returns​

Promise<boolean | Listener>


pinChat​

β–Έ pinChat(id, pin): Promise<boolean>

Pin/Unpin chats

Parameters​

NameTypeDescription
idChatIdThe id of the conversation
pinboolean-

Returns​

Promise<boolean>

boolean true: worked


postImageStatus​

β–Έ postImageStatus(data, caption): Promise<string | boolean | MessageId>

REQUIRES AN IMAGE STORY LICENSE-KEY

Posts an image story.

Parameters​

NameTypeDescription
dataDataURLdata url string data:[<MIME-type>][;charset=<encoding>][;base64],<data>
captionContentThe caption for the story

Returns​

Promise<string | boolean | MessageId>

Promise<string | boolean> returns status id if it worked, false if it didn't


postTextStatus​

β–Έ postTextStatus(text, textRgba, backgroundRgba, font): Promise<string | boolean | MessageId>

REQUIRES A TEXT STORY LICENSE-KEY

Sends a formatted text story.

Parameters​

NameTypeDescription
textContentThe text to be displayed in the story
textRgbastringThe colour of the text in the story in hex format, make sure to add the alpha value also. E.g "#FF00F4F2"
backgroundRgbastringThe colour of the background in the story in hex format, make sure to add the alpha value also. E.g "#4FF31FF2"
fontnumberThe font of the text to be used in the story. This has to be a number. Each number refers to a specific predetermined font. Here are the fonts you can choose from: 0: Sans Serif 1: Serif 2: Norican Regular 3: Bryndan Write 4: Bebasneue Regular 5: Oswald Heavy

Returns​

Promise<string | boolean | MessageId>

Promise<string | boolean> returns status id if it worked, false if it didn't


postVideoStatus​

β–Έ postVideoStatus(data, caption): Promise<string | boolean | MessageId>

REQUIRES A VIDEO STORY LICENSE-KEY

Posts a video story.

Parameters​

NameTypeDescription
dataDataURLdata url string data:[<MIME-type>][;charset=<encoding>][;base64],<data>
captionContentThe caption for the story

Returns​

Promise<string | boolean | MessageId>

Promise<string | boolean> returns status id if it worked, false if it didn't


prepEventData​

β–Έ prepEventData(data, event, extras?): EventPayload

Parameters​

NameType
dataJsonObject
eventSimpleListener
extras?JsonObject

Returns​

EventPayload


promoteParticipant​

β–Έ promoteParticipant(groupId, participantId): Promise<boolean>

Promote Participant to Admin in Group

If not a group chat, returns NOT_A_GROUP_CHAT.

If the chat does not exist, returns GROUP_DOES_NOT_EXIST

If the participantId does not exist in the group chat, returns NOT_A_PARTICIPANT

If the host account is not an administrator, returns INSUFFICIENT_PERMISSIONS

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us'
participantIdContactId | ContactId[]'000000000000@c.us'

Returns​

Promise<boolean>


react​

β–Έ react(messageId, emoji): Promise<boolean>

React to a message

Parameters​

NameTypeDescription
messageIdMessageIdMessage ID of the message you want to react to
emojistring1 single emoji to add to the message as a reacion

Returns​

Promise<boolean>

boolean


refresh​

β–Έ refresh(): Promise<boolean>

Refreshes the page and reinjects all necessary files. This may be useful for when trying to save memory This will attempt to re register all listeners EXCEPT onLiveLocation and onParticipantChanged

Returns​

Promise<boolean>


registerWebhook​

β–Έ registerWebhook(url, events, requestConfig?, concurrency?): Promise<false | Webhook>

The client can now automatically handle webhooks. Use this method to register webhooks.

Parameters​

NameTypeDefault valueDescription
urlstringundefinedThe webhook url
eventsSimpleListener[] | "all"undefinedAn array of SimpleListener enums or all (to register all possible listeners)
requestConfigAxiosRequestConfig<any>{}{} By default the request is a post request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
concurrencynumber5the amount of concurrent requests to be handled by the built in queue. Default is 5.

Returns​

Promise<false | Webhook>

A webhook object. This will include a webhook ID and an array of all successfully registered Listeners.


removeAllListeners​

β–Έ removeAllListeners(): boolean

Returns​

boolean


removeLabel​

β–Έ removeLabel(label, chatId): Promise<boolean>

Removes label from chat, message or contact. Only for business accounts.

Parameters​

NameType
labelstring
chatIdChatId

Returns​

Promise<boolean>


removeListener​

β–Έ removeListener(listener): boolean

//////////////////////// LISTENERS

Parameters​

NameType
listenerSimpleListener

Returns​

boolean


removeParticipant​

β–Έ removeParticipant(groupId, participantId): Promise<boolean>

Remove participant of Group

If not a group chat, returns NOT_A_GROUP_CHAT.

If the chat does not exist, returns GROUP_DOES_NOT_EXIST

If the participantId does not exist in the group chat, returns NOT_A_PARTICIPANT

If the host account is not an administrator, returns INSUFFICIENT_PERMISSIONS

Parameters​

NameTypeDescription
groupIdGroupChatId0000000000-00000000@g.us
participantIdContactId000000000000@c.us

Returns​

Promise<boolean>


removeProduct​

β–Έ removeProduct(productId): Promise<boolean>

Remove a product from the host account's catalog

Parameters​

NameTypeDescription
productIdstringThe id of the product

Returns​

Promise<boolean>

boolean


removeWebhook​

β–Έ removeWebhook(webhookId): Promise<boolean>

Removes a webhook.

Returns true if the webhook was found and removed. false if the webhook was not found and therefore could not be removed. This does not unregister any listeners off of other webhooks.

Retruns

boolean

Parameters​

NameTypeDescription
webhookIdstringThe ID of the webhook

Returns​

Promise<boolean>


reply​

β–Έ reply(to, content, quotedMsgId, sendSeen?): Promise<boolean | MessageId>

Sends a reply to a given message. Please note, you need to have at least sent one normal message to a contact in order for this to work properly.

Parameters​

NameTypeDescription
toChatIdstring chatid
contentContentstring reply text
quotedMsgIdMessageIdstring the msg id to reply to.
sendSeen?booleanboolean If set to true, the chat will 'blue tick' all messages before sending the reply

Returns​

Promise<boolean | MessageId>

Promise<MessageId | false> false if didn't work, otherwise returns message id.


reportSpam
restricted
​

β–Έ reportSpam(id): Promise<boolean>

πŸ…May require restricted license

Use this link to get the correct license.

Report a contact for spam, block them and attempt to clear chat.

Parameters​

NameTypeDescription
idChatId'000000000000@c.us'

Returns​

Promise<boolean>


β–Έ revokeGroupInviteLink(chatId): Promise<string | boolean>

Revokes the current invite link for a group chat. Any previous links will stop working

Parameters​

NameType
chatIdChatId

Returns​

Promise<string | boolean>

Promise<boolean>


sendAdvancedButtons
insiders
​

β–Έ sendAdvancedButtons(to, body, buttons, text, footer, filename): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Send advanced buttons with media body. This is an insiders feature for MD accounts.

caution

Button messages are being progressively handicapped by recipient mobile devices. Some recipients may not see some types of button messages even though their devices will receive them.

Body can be location, image, video or document. Buttons can be quick reply, url or call buttons.

Parameters​

NameTypeDescription
toChatIdchat id
bodystring | LocationButtonBodyThe body of the buttons message
buttonsAdvancedButton[]Array of buttons - limit is 3!
textstring-
footerstringThe footer of the buttons message
filenamestringRequired if body is a file!!

Returns​

Promise<boolean | MessageId>


sendAudio​

β–Έ sendAudio(to, file, quotedMsgId?): Promise<MessageId>

Send an audio file with the default audio player (not PTT/voice message)

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
fileAdvancedFile-
quotedMsgId?MessageIdstring true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

Returns​

Promise<MessageId>


sendBanner​

β–Έ sendBanner(to, base64): Promise<boolean | MessageId>

Send a banner image

Note this is a bit of hack on top of a location message. During testing it is shown to not work on iPhones.

Parameters​

NameTypeDescription
toChatId
base64Base64base64 encoded jpeg

Returns​

Promise<boolean | MessageId>


sendButtons
insiders
​

β–Έ sendButtons(to, body, buttons, title?, footer?): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Send generic quick reply buttons. This is an insiders feature for MD accounts.

Parameters​

NameTypeDescription
toChatIdchat id
bodystring | LocationButtonBodyThe body of the buttons message
buttonsButton[]Array of buttons - limit is 3!
title?stringThe title/header of the buttons message
footer?stringThe footer of the buttons message

Returns​

Promise<boolean | MessageId>


sendContact​

β–Έ sendContact(to, contactId): Promise<boolean | MessageId>

Sends contact card to given chat id. You can use this to send multiple contacts but they will show up as multiple single-contact messages.

Parameters​

NameTypeDescription
toChatId'xxxx@c.us'
contactIdContactId | ContactId[]-

Returns​

Promise<boolean | MessageId>


sendCustomProduct​

β–Έ sendCustomProduct(to, image, productData): Promise<boolean | MessageId>

Deprecated

Feature Currently only available with Premium License accounts.

Send a custom product to a chat. Please see CustomProduct for details.

Caveats:

  • URL will not work (unable to click), you will have to send another message with the URL.
  • Recipient will see a thin banner under picture that says "Something went wrong"
  • This will only work if you have at least 1 product already in your catalog
  • Only works on Business accounts

Parameters​

NameType
toChatId
imageDataURL
productDataCustomProduct

Returns​

Promise<boolean | MessageId>


sendEmoji​

β–Έ sendEmoji(to, emojiId, messageId?): Promise<string | boolean | MessageId>

Send a discord emoji to a chat as a sticker

Parameters​

NameTypeDescription
toChatIdChatId The chat id you want to send the webp sticker to
emojiIdstringThe discord emoji id without indentifying chars. In discord you would write :who:, here use who
messageId?MessageIdmessage id of the message you want this sticker to reply to. {@license:insiders@}

Returns​

Promise<string | boolean | MessageId>


sendFile​

β–Έ sendFile(to, file, filename, caption, quotedMsgId?, waitForId?, ptt?, withoutPreview?, hideTags?, viewOnce?, requestConfig?): Promise<boolean | MessageId>

Sends a file to given chat, with caption or not, using base64. This is exactly the same as sendImage

Please note that any file that resolves to mime-type octet-stream will, by default, resolve to an MP4 file.

If you want a specific filetype, then explcitly select the correct mime-type from https://www.iana.org/assignments/media-types/media-types.xhtml

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
fileAdvancedFileDataURL data:image/xxx;base64,xxx or the RELATIVE (should start with ./ or ../) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg).
filenamestringstring xxxxx
captionContentstring xxxxx With an INSIDERS LICENSE-KEY you can also tag people in groups with @[number]. For example if you want to mention the user with the number 44771234567, just add @44771234567 in the caption.
quotedMsgId?MessageIdstring true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
waitForId?booleanboolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
ptt?booleanboolean default: false set this to true if you want to send the file as a push to talk file.
withoutPreview?booleanboolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
hideTags?booleanboolean default: false [INSIDERS] set this to try silent tag someone in the caption
viewOnce?boolean-
requestConfig?any-

Returns​

Promise<boolean | MessageId>

Promise <boolean | MessageId> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true


sendFileFromUrl​

β–Έ sendFileFromUrl(to, url, filename, caption, quotedMsgId?, requestConfig?, waitForId?, ptt?, withoutPreview?, hideTags?, viewOnce?): Promise<boolean | MessageId>

Sends a file by Url or custom options

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
urlstringstring https://i.giphy.com/media/oYtVHSxngR3lC/200w.mp4
filenamestringstring 'video.mp4'
captionContentstring xxxxx
quotedMsgId?MessageIdstring true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
requestConfigAxiosRequestConfig<any>{} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
waitForId?booleanboolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
ptt?booleanboolean default: false set this to true if you want to send the file as a push to talk file.
withoutPreview?booleanboolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
hideTags?boolean-
viewOnce?boolean-

Returns​

Promise<boolean | MessageId>


sendGiphy​

β–Έ sendGiphy(to, giphyMediaUrl, caption): Promise<MessageId>

Sends a video to given chat as a gif by using a giphy link, with caption or not, using base64

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
giphyMediaUrlstringstring https://media.giphy.com/media/oYtVHSxngR3lC/giphy.gif => https://i.giphy.com/media/oYtVHSxngR3lC/200w.mp4
captionContentstring xxxxx

Returns​

Promise<MessageId>


sendGiphyAsSticker​

β–Έ sendGiphyAsSticker(to, giphyMediaUrl): Promise<string | boolean | MessageId>

Send a giphy GIF as an animated sticker.

Parameters​

NameTypeDescription
toChatIdChatId
giphyMediaUrlstring | URLURL | string This is the giphy media url and has to be in the format https://media.giphy.com/media/RJKHjCAdsAfQPn03qQ/source.gif or it can be just the id RJKHjCAdsAfQPn03qQ

Returns​

Promise<string | boolean | MessageId>


sendImage​

β–Έ sendImage(to, file, filename, caption, quotedMsgId?, waitForId?, ptt?, withoutPreview?, hideTags?, viewOnce?, requestConfig?): Promise<boolean | MessageId>

Sends a image to given chat, with caption or not, using base64

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
fileAdvancedFileDataURL data:image/xxx;base64,xxx or the RELATIVE (should start with ./ or ../) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg).
filenamestringstring xxxxx
captionContentstring xxxxx
quotedMsgId?MessageId-
waitForId?boolean-
ptt?boolean-
withoutPreview?boolean-
hideTags?booleanboolean default: false [INSIDERS] set this to try silent tag someone in the caption
viewOnce?boolean-
requestConfig?any-

Returns​

Promise<boolean | MessageId>

Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true


sendImageAsSticker​

β–Έ sendImageAsSticker(to, image, stickerMetadata?): Promise<string | boolean | MessageId>

This function takes an image (including animated GIF) and sends it as a sticker to the recipient. This is helpful for sending semi-ephemeral things like QR codes. The advantage is that it will not show up in the recipients gallery. This function automatiicaly converts images to the required webp format.

Parameters​

NameType
toChatId
imagestring | Base64 | DataURL | Buffer
stickerMetadata?StickerMetadata

Returns​

Promise<string | boolean | MessageId>


sendImageAsStickerAsReply
insiders
​

β–Έ sendImageAsStickerAsReply(to, image, messageId, stickerMetadata?): Promise<string | boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

This function takes an image and sends it as a sticker to the recipient as a reply to another message.

Parameters​

NameTypeDescription
toChatIdThe recipient id.
imagestring | Base64 | DataURL | Buffer-
messageIdMessageIdThe id of the message to reply to
stickerMetadata?StickerMetadataSticker metadata

Returns​

Promise<string | boolean | MessageId>


sendImageWithProduct​

β–Έ sendImageWithProduct(to, image, caption, bizNumber, productId): Promise<boolean | MessageId>

Sends product with image to chat

Parameters​

NameTypeDescription
toChatId-
imageBase64-
captionContentstring the caption you want to add to this message
bizNumberContactIdstring the @c.us number of the business account from which you want to grab the product
productIdstringstring the id of the product within the main catalog of the aforementioned business

Returns​

Promise<boolean | MessageId>


sendLinkWithAutoPreview​

β–Έ sendLinkWithAutoPreview(to, url, text?, thumbnail?): Promise<boolean | MessageId>

Automatically sends a link with the auto generated link preview. You can also add a custom message.

Parameters​

NameTypeDescription
toChatId-
urlstringstring A link.
text?Contentstring Custom text as body of the message, this needs to include the link or it will be appended after the link.
thumbnail?Base64Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.

Returns​

Promise<boolean | MessageId>


sendListMessage
insiders
​

β–Έ sendListMessage(to, sections, title, description, actionText): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Send a list message. This will not work when being sent from business accounts!

Parameters​

NameTypeDescription
toChatId
sectionsSection[]The Sections of rows for the list message
titlestringThe title of the list message
descriptionstringThe description of the list message
actionTextstringThe action text of the list message

Returns​

Promise<boolean | MessageId>


sendLocation​

β–Έ sendLocation(to, lat, lng, loc, address?, url?): Promise<boolean | MessageId>

Note: address and url are parameters available to insiders only.

Sends a location message to given chat

Parameters​

NameTypeDescription
toChatIdchat id: xxxxx@c.us
latstringlatitude: '51.5074'
lngstringlongitude: '0.1278'
locstringlocation text: 'LONDON!'
address?stringaddress text: '1 Regents Park!'
url?stringaddress text link: 'https://example.com'

Returns​

Promise<boolean | MessageId>


sendMessageWithThumb​

β–Έ sendMessageWithThumb(thumb, url, title, description, text, chatId): Promise<boolean | MessageId>

Sends a link to a chat that includes a link preview.

Parameters​

NameTypeDescription
thumbstringThe base 64 data of the image you want to use as the thunbnail. This should be no more than 200x200px. Note: Dont need data url on this param
urlstringThe link you want to send
titlestringThe title of the link
descriptionstringThe long description of the link preview
textContentThe text you want to inslude in the message section. THIS HAS TO INCLUDE THE URL otherwise the url will be prepended to the text automatically.
chatIdChatIdThe chat you want to send this message to.

Returns​

Promise<boolean | MessageId>


sendMp4AsSticker​

β–Έ sendMp4AsSticker(to, file, processOptions?, stickerMetadata?, messageId?): Promise<string | boolean | MessageId>

Use this to send an mp4 file as a sticker. This can also be used to convert GIFs from the chat because GIFs in WA are actually tiny mp4 files.

Parameters​

NameTypeDefault valueDescription
toChatIdundefinedChatId The chat id you want to send the webp sticker to
filestring | Base64 | DataURL | BufferundefinedDataURL, Base64, URL (string GET), Relative filepath (string), or Buffer of the mp4 file
processOptionsMp4StickerConversionProcessOptionsdefaultProcessOptions-
stickerMetadata?StickerMetadataundefined-
messageId?MessageIdundefinedmessage id of the message you want this sticker to reply to. {@license:insiders@}

Returns​

Promise<string | boolean | MessageId>


sendMultipleContacts
insiders
​

β–Έ sendMultipleContacts(to, contactIds): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Sends multiple contacts as a single message

Parameters​

NameTypeDescription
toChatId'xxxx@c.us'
contactIdsContactId[]-

Returns​

Promise<boolean | MessageId>


sendPaymentRequest​

β–Έ sendPaymentRequest(to, amount, currency, message?): Promise<boolean | MessageId>

[UNTESTED - REQUIRES FEEDBACK] Sends a payment request message to given chat

Parameters​

NameTypeDescription
toChatIdchat id: xxxxx@c.us
amountnumbernumber the amount to request in 1000 format (e.g Β£10 => 10000)
currencystringstring The 3 letter currency code
message?stringstring optional message to send with the payment request

Returns​

Promise<boolean | MessageId>


sendPoll​

β–Έ sendPoll(to, name, options): Promise<MessageId>

Send a poll to a group chat

Parameters​

NameTypeDescription
toGroupChatIdchat id - a group chat is required
namestringthe name of the poll
optionsstring[]an array of poll options

Returns​

Promise<MessageId>


sendProduct
insiders
​

β–Έ sendProduct(chatId, productId): Promise<MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Send a product to a chat

Parameters​

NameTypeDescription
chatIdChatIdThe chatId
productIdstringThe id of the product

Returns​

Promise<MessageId>

MessageID


sendPtt​

β–Έ sendPtt(to, file, quotedMsgId?): Promise<MessageId>

Attempts to send a file as a voice note. Useful if you want to send an mp3 file.

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
fileAdvancedFilebase64 data:image/xxx;base64,xxx or the path of the file you want to send.
quotedMsgId?MessageIdstring true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

Returns​

Promise<MessageId>

Promise <boolean | string> This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true


sendRawWebpAsSticker​

β–Έ sendRawWebpAsSticker(to, webpBase64, animated?): Promise<string | boolean | MessageId>

You can use this to send a raw webp file.

Parameters​

NameTypeDefault valueDescription
toChatIdundefinedChatId The chat id you want to send the webp sticker to
webpBase64Base64undefinedBase64 The base64 string of the webp file. Not DataURl
animatedbooleanfalseBoolean Set to true if the webp is animated. Default false

Returns​

Promise<string | boolean | MessageId>


sendRawWebpAsStickerAsReply
insiders
​

β–Έ sendRawWebpAsStickerAsReply(to, messageId, webpBase64, animated?): Promise<string | boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

You can use this to send a raw webp file.

Parameters​

NameTypeDefault valueDescription
toChatIdundefinedChatId The chat id you want to send the webp sticker to
messageIdMessageIdundefinedMessageId Message ID of the message to reply to
webpBase64Base64undefinedBase64 The base64 string of the webp file. Not DataURl
animatedbooleanfalseBoolean Set to true if the webp is animated. Default false

Returns​

Promise<string | boolean | MessageId>


sendReplyWithMentions​

β–Έ sendReplyWithMentions(to, content, replyMessageId, hideTags?, mentions?): Promise<boolean | MessageId>

Sends a reply to given chat that includes mentions, replying to the provided replyMessageId. In order to use this method correctly you will need to send the text like this: "@4474747474747 how are you?" Basically, add a @ symbol before the number of the contact you want to mention.

Parameters​

NameTypeDescription
toChatIdchat id: xxxxx@c.us
contentContenttext message
replyMessageIdMessageIdid of message to reply to
hideTags?booleanRemoves all tags within the message
mentions?ContactId[]You can optionally add an array of contact IDs to tag only specific people

Returns​

Promise<boolean | MessageId>


sendSeen​

β–Έ sendSeen(chatId): Promise<boolean>

Sets a chat status to seen. Marks all messages as ack: 3

Parameters​

NameTypeDescription
chatIdChatIdchat id: xxxxx@c.us

Returns​

Promise<boolean>


sendStickerfromUrl​

β–Έ sendStickerfromUrl(to, url, requestConfig?, stickerMetadata?): Promise<string | boolean | MessageId>

Sends a sticker (including GIF) from a given URL

Parameters​

NameTypeDescription
toChatId-
urlstring-
requestConfigAxiosRequestConfig<any>{} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
stickerMetadata?StickerMetadata-

Returns​

Promise<string | boolean | MessageId>

Promise<MessageId | boolean>


sendStickerfromUrlAsReply
insiders
​

β–Έ sendStickerfromUrlAsReply(to, url, messageId, requestConfig?, stickerMetadata?): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Sends a sticker from a given URL

Parameters​

NameTypeDescription
toChatIdThe recipient id.
urlstringThe url of the image
messageIdMessageIdThe id of the message to reply to
requestConfigAxiosRequestConfig<any>{} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
stickerMetadata?StickerMetadata-

Returns​

Promise<boolean | MessageId>

Promise<MessageId | boolean>


sendText
restricted
​

β–Έ sendText(to, content): Promise<boolean | MessageId>

πŸ…May require restricted license

Use this link to get the correct license.

Sends a text message to given chat

A license is NOT required to send messages with existing chats/contacts. A license is only required for starting conversations with new numbers.

Parameters​

NameTypeDescription
toChatIdchat id: xxxxx@c.us
contentContenttext message

Returns​

Promise<boolean | MessageId>


sendTextWithMentions​

β–Έ sendTextWithMentions(to, content, hideTags?, mentions?): Promise<boolean | MessageId>

Sends a text message to given chat that includes mentions. In order to use this method correctly you will need to send the text like this: "@4474747474747 how are you?" Basically, add a @ symbol before the number of the contact you want to mention.

Parameters​

NameTypeDescription
toChatIdchat id: xxxxx@c.us
contentContenttext message
hideTags?booleanRemoves all tags within the message
mentions?ContactId[]You can optionally add an array of contact IDs to tag only specific people

Returns​

Promise<boolean | MessageId>


sendVCard​

β–Έ sendVCard(chatId, vcard, contactName?, contactNumber?): Promise<boolean>

Send VCARD

Parameters​

NameTypeDescription
chatIdChatId'000000000000@c.us'
vcardstringvcard as a string, you can send multiple contacts vcard also.
contactName?stringThe display name for the contact. Ignored on multiple vcards
contactNumber?stringIf supplied, this will be injected into the vcard (VERSION 3 ONLY FROM VCARDJS) with the WA id to make it show up with the correct buttons on WA. The format of this param should be including country code, without any other formating. e.g: 4477777777777 Ignored on multiple vcards

Returns​

Promise<boolean>


sendVideoAsGif​

β–Έ sendVideoAsGif(to, file, filename, caption, quotedMsgId?, requestConfig?): Promise<MessageId>

Sends a video to given chat as a gif, with caption or not, using base64

Parameters​

NameTypeDescription
toChatIdchat id xxxxx@c.us
fileAdvancedFileDataURL data:image/xxx;base64,xxx or the RELATIVE (should start with ./ or ../) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg).
filenamestringstring xxxxx
captionContentstring xxxxx
quotedMsgId?MessageIdstring true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
requestConfigAxiosRequestConfig<any>{} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config

Returns​

Promise<MessageId>


β–Έ sendYoutubeLink(to, url, text?, thumbnail?): Promise<boolean | MessageId>

Automatically sends a youtube link with the auto generated link preview. You can also add a custom message.

Parameters​

NameTypeDefault valueDescription
toChatIdundefined-
urlstringundefinedstring A youtube link.
textContent''string Custom text as body of the message, this needs to include the link or it will be appended after the link.
thumbnail?Base64undefinedstring Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.

Returns​

Promise<boolean | MessageId>


setChatBackgroundColourHex
insiders
​

β–Έ setChatBackgroundColourHex(hex): Promise<boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Set the wallpaper background colour

Parameters​

NameTypeDescription
hexstring'#FFF123'

Returns​

Promise<boolean>


setChatEphemeral
insiders
​

β–Έ setChatEphemeral(chatId, ephemeral): Promise<boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Turn the ephemeral setting in a chat to on or off

Parameters​

NameTypeDescription
chatIdChatIdThe ID of the chat
ephemeralboolean | EphemeralDurationtrue to turn on the ephemeral setting to 1 day, false to turn off the ephemeral setting. Other options: 604800 \| 7776000

Returns​

Promise<boolean>

Promise<boolean> true if the setting was set, false if the chat does not exist


setChatState​

β–Έ setChatState(chatState, chatId): Promise<boolean>

Sets the chat state

Parameters​

NameTypeDescription
chatStateChatStateThe state you want to set for the chat. Can be TYPING (0), RECRDING (1) or PAUSED (2).
chatIdChatId

Returns​

Promise<boolean>


setGroupDescription​

β–Έ setGroupDescription(groupId, description): Promise<boolean>

Change the group chant description

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us' the group id.
descriptionstringstring The new group description

Returns​

Promise<boolean>

boolean true if action completed successfully.


setGroupEditToAdminsOnly​

β–Έ setGroupEditToAdminsOnly(groupId, onlyAdmins): Promise<boolean>

Change who can and cannot edit a groups details

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us' the group id.
onlyAdminsbooleanboolean set to true if you want only admins to be able to speak in this group. false if you want to allow everyone to speak in the group

Returns​

Promise<boolean>

boolean true if action completed successfully.


setGroupIcon​

β–Έ setGroupIcon(groupId, image): Promise<boolean>

Change the icon for the group chat

Parameters​

NameTypeDescription
groupIdGroupChatId123123123123_1312313123@g.us The id of the group
imageDataURL-

Returns​

Promise<boolean>

boolean true if it was set, false if it didn't work. It usually doesn't work if the image file is too big.


setGroupIconByUrl​

β–Έ setGroupIconByUrl(groupId, url, requestConfig?): Promise<boolean>

Change the icon for the group chat

Parameters​

NameTypeDescription
groupIdGroupChatId123123123123_1312313123@g.us The id of the group
urlstring-
requestConfigAxiosRequestConfig<any>{} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config

Returns​

Promise<boolean>

boolean true if it was set, false if it didn't work. It usually doesn't work if the image file is too big.


setGroupTitle
insiders
​

β–Έ setGroupTitle(groupId, title): Promise<boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Change the group chat title

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us' the group id.
titlestringstring The new group title

Returns​

Promise<boolean>

boolean true if action completed successfully.


setGroupToAdminsOnly​

β–Έ setGroupToAdminsOnly(groupId, onlyAdmins): Promise<boolean>

Change who can and cannot speak in a group

Parameters​

NameTypeDescription
groupIdGroupChatId'0000000000-00000000@g.us' the group id.
onlyAdminsbooleanboolean set to true if you want only admins to be able to speak in this group. false if you want to allow everyone to speak in the group

Returns​

Promise<boolean>

boolean true if action completed successfully.


setMyName​

β–Έ setMyName(newName): Promise<boolean>

Set your profile name

Please note, this does not work on business accounts!

Parameters​

NameTypeDescription
newNamestringString new name to set for your profile

Returns​

Promise<boolean>


setMyStatus​

β–Έ setMyStatus(newStatus): Promise<boolean | void>

set your about me

Parameters​

NameTypeDescription
newStatusstringString new profile status

Returns​

Promise<boolean | void>


setPresence​

β–Έ setPresence(available): Promise<boolean | void>

Set presence to available or unavailable.

Parameters​

NameTypeDescription
availablebooleanif true it will set your presence to 'online', false will set to unavailable (i.e no 'online' on recipients' phone);

Returns​

Promise<boolean | void>


setProfilePic​

β–Έ setProfilePic(data): Promise<boolean>

Sets the profile pic of the host number.

Parameters​

NameTypeDescription
dataDataURLstring data url image string.

Returns​

Promise<boolean>

Promise<boolean> success if true


simulateRecording​

β–Έ simulateRecording(to, on): Promise<boolean>

Simulate '...recording' in chat

Parameters​

NameTypeDescription
toChatId'xxxx@c.us'
onbooleanturn on similated recording, false to turn it off you need to manually turn this off.

Returns​

Promise<boolean>


simulateTyping​

β–Έ simulateTyping(to, on): Promise<boolean>

Simulate '...typing' in chat

Parameters​

NameTypeDescription
toChatId'xxxx@c.us'
onbooleanturn on similated typing, false to turn it off you need to manually turn this off.

Returns​

Promise<boolean>


starMessage​

β–Έ starMessage(messageId): Promise<boolean>

Star a message

Parameters​

NameTypeDescription
messageIdMessageIdMessage ID of the message you want to star

Returns​

Promise<boolean>

true


syncContacts​

β–Έ syncContacts(): Promise<boolean>

Syncs contacts with phone. This promise does not resolve so it will instantly return true.

Returns​

Promise<boolean>


tagEveryone
insiders
​

β–Έ tagEveryone(groupId, content, hideTags?, formatting?, messageBeforeTags?): Promise<boolean | MessageId>

πŸ…May require insiders license

Use this link to get the correct license.

Tags everyone in the group with a message

Mention

to indicate the actual tag.

Default

@mention

Parameters​

NameTypeDescription
groupIdGroupChatIdgroup chat id: xxxxx@g.us
contentContenttext message to add under all of the tags
hideTags?booleanRemoves all tags within the message
formatting?stringThe formatting of the tags. Use
messageBeforeTags?booleanset to true to show the message before all of the tags

Returns​

Promise<boolean | MessageId>

Promise<MessageId>


testButtons​

β–Έ testButtons(chatId): Promise<any>

Test the button commands on MD accounts with an insiders key. This is a temporary feature to help fix issue #2658

Parameters​

NameType
chatIdChatId

Returns​

Promise<any>


testCallback​

β–Έ testCallback(callbackToTest, testData): Promise<boolean>

Use this simple command to test firing callback events.

Parameters​

NameType
callbackToTestSimpleListener
testDataany

Returns​

Promise<boolean>

false if the callback was not registered/does not exist


unmuteChat
insiders
​

β–Έ unmuteChat(chatId): Promise<string | number | boolean>

πŸ…May require insiders license

Use this link to get the correct license.

Unmutes a conversation.

Parameters​

NameType
chatIdChatId

Returns​

Promise<string | number | boolean>

boolean true: worked or error code or message


unstarMessage​

β–Έ unstarMessage(messageId): Promise<boolean>

Unstar a message

Parameters​

NameTypeDescription
messageIdMessageIdMessage ID of the message you want to unstar

Returns​

Promise<boolean>

true


updateWebhook​

β–Έ updateWebhook(webhookId, events): Promise<false | Webhook>

Update registered events for a specific webhook. This will override all existing events. If you'd like to remove all listeners from a webhook, consider using removeWebhook.

In order to update authentication details for a webhook, remove it completely and then reregister it with the correct credentials.

Parameters​

NameType
webhookIdstring
eventsSimpleListener[] | "all"

Returns​

Promise<false | Webhook>


waitAllQEmpty​

β–Έ waitAllQEmpty(): Promise<true | void[]>

Wait for all queues to be empty

Returns​

Promise<true | void[]>


waitWhQIdle​

β–Έ waitWhQIdle(): Promise<true | void>

Wait for the webhook queue to become idle. This is useful for ensuring webhooks are cleared before ending a process.

Returns​

Promise<true | void>

Events​

onAck​

β–Έ onAck(fn): Promise<boolean | Listener>

Listens to messages acknowledgement Changes

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback function that handles a Message as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onAddedToGroup​

β–Έ onAddedToGroup(fn): Promise<boolean | Listener>

Fires callback with Chat object every time the host phone is added to a group.

Parameters​

NameTypeDescription
fn(chat: Chat) => anycallback function that handles a Chat (group chat) as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onAnyMessage​

β–Έ onAnyMessage(fn, queueOptions?): Promise<boolean | Listener>

Listens to all new messages

Fires

Message

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback
queueOptions?Options<default, DefaultAddOptions>PQueue options. Set to {} for default PQueue.

Returns​

Promise<boolean | Listener>


onBattery​

β–Έ onBattery(fn): Promise<boolean | Listener>

Deprecated

Listens to battery changes

caution

This will most likely not work with multi-device mode (the only remaining mode) since the session is no longer connected to the phone but directly to WA servers.

Fires

number

Parameters​

NameTypeDescription
fn(battery: number) => voidcallback

Returns​

Promise<boolean | Listener>


onBroadcast​

β–Έ onBroadcast(fn): Promise<boolean | Listener>

Listens to broadcast messages

Fires

Message

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback

Returns​

Promise<boolean | Listener>


onButton​

β–Έ onButton(fn): Promise<boolean | Listener>

Listens to button message responses

Fires

Message

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback

Returns​

Promise<boolean | Listener>


onCallState​

β–Έ onCallState(fn): Promise<boolean | Listener>

Listens to changes on call state

Parameters​

NameType
fn(call: Call) => void

Returns​

Promise<boolean | Listener>

Observable stream of call objects


onChatDeleted​

β–Έ onChatDeleted(fn): Promise<boolean | Listener>

Listens to when a chat is deleted by the host account

Fires

Chat

Parameters​

NameTypeDescription
fn(chat: Chat) => voidcallback

Returns​

Promise<boolean | Listener>


onChatOpened
insiders
​

β–Έ onChatOpened(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Fires callback with the relevant chat id every time the user clicks on a chat. This will only work in headful mode.

Parameters​

NameTypeDescription
fn(chat: Chat) => anycallback function that handles a ChatId as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onChatState
insiders
​

β–Έ onChatState(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Listens to chat state, including when a specific user is recording and typing within a group chat.

Here is an example of the fired object:

Fires

{
"chat": "00000000000-1111111111@g.us", //the chat in which this state is occuring
"user": "22222222222@c.us", //the user that is causing this state
"state": "composing, //can also be 'available', 'unavailable', 'recording' or 'composing'
}

Parameters​

NameType
fn(chatState: ChatState) => void

Returns​

Promise<boolean | Listener>


onContactAdded
insiders
​

β–Έ onContactAdded(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Fires callback with contact id when a new contact is added on the host phone.

Parameters​

NameTypeDescription
fn(chat: Chat) => anycallback function that handles a Chat as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onGlobalParticipantsChanged​

β–Έ onGlobalParticipantsChanged(fn): Promise<boolean | Listener>

Listens to add and remove events on Groups on a global level. It is memory efficient and doesn't require a specific group id to listen to.

Parameters​

NameTypeDescription
fn(participantChangedEvent: ParticipantChangedEventModel) => voidcallback function that handles a ParticipantChangedEventModel as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onGroupChange​

β–Έ onGroupChange(fn): Promise<boolean | Listener>

Listens to all group (gp2) events. This can be useful if you want to catch when a group title, subject or picture is changed.

Parameters​

NameTypeDescription
fn(genericGroupChangeEvent: GenericGroupChangeEvent) => voidcallback function that handles a ParticipantChangedEventModel as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onIncomingCall​

β–Έ onIncomingCall(fn): Promise<boolean | Listener>

Listens to new incoming calls

Parameters​

NameType
fn(call: Call) => void

Returns​

Promise<boolean | Listener>

Observable stream of call request objects


onLabel​

β–Έ onLabel(fn): Promise<boolean | Listener>

Listens to label change events

Fires

Label

Parameters​

NameTypeDescription
fn(label: Label) => voidcallback

Returns​

Promise<boolean | Listener>


onLiveLocation​

β–Έ onLiveLocation(chatId, fn): Promise<boolean>

Listens to live locations from a chat that already has valid live locations

Emits

<LiveLocationChangedEvent> LiveLocationChangedEvent

Parameters​

NameTypeDescription
chatIdChatIdthe chat from which you want to subscribes to live location updates
fn(liveLocationChangedEvent: LiveLocationChangedEvent) => voidcallback that takes in a LiveLocationChangedEvent

Returns​

Promise<boolean>

boolean, if returns false then there were no valid live locations in the chat of chatId


onLogout​

β–Έ onLogout(fn, priority?): Promise<boolean>

Listens to a log out event

Fires

true

Parameters​

NameTypeDescription
fn(loggedOut?: boolean) => anycallback
priority?numberA priority of -1 will mean the callback will be triggered after all the non -1 callbacks

Returns​

Promise<boolean>


onMessage​

β–Έ onMessage(fn, queueOptions?): Promise<boolean | Listener>

Listens to incoming messages

Fires

Message

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback
queueOptions?Options<default, DefaultAddOptions>PQueue options. Set to {} for default PQueue.

Returns​

Promise<boolean | Listener>


onMessageDeleted​

β–Έ onMessageDeleted(fn): Promise<boolean | Listener>

Listens to when a message is deleted by a recipient or the host account

Fires

Message

Parameters​

NameTypeDescription
fn(message: Message) => voidcallback

Returns​

Promise<boolean | Listener>


onParticipantsChanged​

β–Έ onParticipantsChanged(groupId, fn, legacy?): Promise<boolean | Listener>

Listens to add and remove events on Groups. This can no longer determine who commited the action and only reports the following events add, remove, promote, demote

Parameters​

NameTypeDefault valueDescription
groupIdGroupChatIdundefinedgroup id: xxxxx-yyyy@c.us
fn(participantChangedEvent: ParticipantChangedEventModel) => voidundefinedcallback
legacybooleanfalse-

Returns​

Promise<boolean | Listener>

Observable stream of participantChangedEvent


onPlugged​

β–Έ onPlugged(fn): Promise<boolean | Listener>

Listens to when host device is plugged/unplugged

Fires

boolean true if plugged, false if unplugged

Parameters​

NameTypeDescription
fn(plugged: boolean) => voidcallback

Returns​

Promise<boolean | Listener>


onPollVote​

β–Έ onPollVote(fn): Promise<boolean | Listener>

Listens to poll vote events

Fires

PollData

Parameters​

NameTypeDescription
fn(pollDate: PollData) => voidcallback

Returns​

Promise<boolean | Listener>


onReaction
insiders
​

β–Έ onReaction(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Listens to reaction add and change events

Fires

ReactionEvent

Parameters​

NameTypeDescription
fn(reactionEvent: ReactionEvent) => voidcallback

Returns​

Promise<boolean | Listener>


onRemovedFromGroup
insiders
​

β–Έ onRemovedFromGroup(fn): Promise<boolean | Listener>

πŸ…May require insiders license

Use this link to get the correct license.

Fires callback with Chat object every time the host phone is removed to a group.

Parameters​

NameTypeDescription
fn(chat: Chat) => anycallback function that handles a Chat (group chat) as the first and only parameter.

Returns​

Promise<boolean | Listener>

true if the callback was registered


onStateChanged​

β–Έ onStateChanged(fn): Promise<boolean | Listener>

Listens to changes in state

Fires

STATE observable sream of states

Parameters​

NameType
fn(state: STATE) => void

Returns​

Promise<boolean | Listener>


onStory
restricted
​

β–Έ onStory(fn): Promise<boolean | Listener>

πŸ…May require restricted license

Use this link to get the correct license.

Listens to when a contact posts a new story.

Fires

e.g

{
from: '123456789@c.us'
id: 'false_132234234234234@status.broadcast'
}

Parameters​

NameTypeDescription
fn(story: Message) => voidcallback

Returns​

Promise<boolean | Listener>