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>


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>

Deletes all your existing statuses.

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>

Consumes a list of id strings of statuses to delete.

Parametersā€‹

NameTypeDescription
statusesToDeletestring | string[]string [] | stringan array of ids of statuses 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

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.


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>
onChatDeleteddefault<default, DefaultAddOptions>
onChatOpeneddefault<default, DefaultAddOptions>
onChatStatedefault<default, DefaultAddOptions>
onContactAddeddefault<default, DefaultAddOptions>
onGlobalParticipantsChangeddefault<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>
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[]>

retrieves all existing statuses.

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


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ā€‹

ā–ø getStoryViewers(id): Promise<ContactId[]>

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

Parametersā€‹

NameTypeDescription
idstringstring The id of the story Only works with a Story License Key

Returnsā€‹

Promise<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?): (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

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>

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?): 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-

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?): 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-

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>


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.
quotedMsgIdMessageIdstring 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>

Listens to battery changes

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>


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


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>


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ā€‹

ā–ø onStory(fn): Promise<boolean | Listener>

Requires a Story License Key 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>