Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

Hierarchy

  • Client

Index

Events

Methods

Events

onAck

  • onAck(fn: (message: Message) => void): Promise<boolean | Listener>
  • Listens to messages acknowledgement Changes

    Parameters

    • fn: (message: Message) => void

      callback function that handles a Message as the first and only parameter.

    Returns Promise<boolean | Listener>

    true if the callback was registered

onAddedToGroup

  • onAddedToGroup(fn: (chat: Chat) => any): Promise<boolean | Listener>
  • Fires callback with Chat object every time the host phone is added to a group.

    Parameters

    • fn: (chat: Chat) => any

      callback function that handles a Chat (group chat) as the first and only parameter.

        • Parameters

          Returns any

    Returns Promise<boolean | Listener>

    true if the callback was registered

onAnyMessage

  • onAnyMessage(fn: (message: Message) => void, queueOptions?: Options<default, DefaultAddOptions>): Promise<boolean | Listener>
  • Listens to all new messages

    fires

    Message

    Parameters

    • fn: (message: Message) => void

      callback

    • Optional queueOptions: Options<default, DefaultAddOptions>

      PQueue options. Set to {} for default PQueue.

    Returns Promise<boolean | Listener>

onBattery

  • onBattery(fn: (battery: number) => void): Promise<boolean | Listener>
  • Listens to battery changes

    fires

    number

    Parameters

    • fn: (battery: number) => void

      callback

        • (battery: number): void
        • Parameters

          • battery: number

          Returns void

    Returns Promise<boolean | Listener>

onButton

  • onButton(fn: (chat: Chat) => void): Promise<boolean | Listener>
  • Listens to button message responses

    fires

    Message

    Parameters

    • fn: (chat: Chat) => void

      callback

        • (chat: Chat): void
        • Parameters

          Returns void

    Returns Promise<boolean | Listener>

onChatDeleted

  • onChatDeleted(fn: (chat: Chat) => void): Promise<boolean | Listener>
  • Listens to when a chat is deleted by the host account

    fires

    Chat

    Parameters

    • fn: (chat: Chat) => void

      callback

        • (chat: Chat): void
        • Parameters

          Returns void

    Returns Promise<boolean | Listener>

onChatOpened

  • onChatOpened(fn: (chat: Chat) => any): Promise<boolean | Listener>
  • Fires callback with the relevant chat id every time the user clicks on a chat. This will only work in headful mode.

    Parameters

    • fn: (chat: Chat) => any

      callback function that handles a ChatId as the first and only parameter.

        • Parameters

          Returns any

    Returns Promise<boolean | Listener>

    true if the callback was registered

onChatState

  • onChatState(fn: (chatState: ChatState) => void): Promise<boolean | Listener>
  • Listens to chat state, including when a specific user is recording and typing within a group chat.

    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

    Returns Promise<boolean | Listener>

onContactAdded

  • onContactAdded(fn: (chat: Chat) => any): Promise<boolean | Listener>
  • Fires callback with contact id when a new contact is added on the host phone.

    Parameters

    • fn: (chat: Chat) => any

      callback function that handles a Chat as the first and only parameter.

        • Parameters

          Returns any

    Returns Promise<boolean | Listener>

    true if the callback was registered

onGlobalParticipantsChanged

onIncomingCall

  • onIncomingCall(fn: (call: Call) => void): Promise<boolean | Listener>
  • Listens to new incoming calls

    Parameters

    • fn: (call: Call) => void
        • (call: Call): void
        • Parameters

          Returns void

    Returns Promise<boolean | Listener>

    Observable stream of call request objects

onLiveLocation

  • emits

    LiveLocationChangedEvent

    Parameters

    Returns Promise<boolean>

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

onLogout

  • onLogout(fn: (loggedOut?: boolean) => any): Promise<boolean>
  • Listens to a log out event

    fires

    true

    Parameters

    • fn: (loggedOut?: boolean) => any

      callback

        • (loggedOut?: boolean): any
        • Parameters

          • Optional loggedOut: boolean

          Returns any

    Returns Promise<boolean>

onMessage

  • onMessage(fn: (message: Message) => void, queueOptions?: Options<default, DefaultAddOptions>): Promise<boolean | Listener>
  • Listens to incoming messages

    fires

    Message

    Parameters

    • fn: (message: Message) => void

      callback

    • Optional queueOptions: Options<default, DefaultAddOptions>

      PQueue options. Set to {} for default PQueue.

    Returns Promise<boolean | Listener>

onMessageDeleted

  • onMessageDeleted(fn: (message: Message) => void): Promise<boolean | Listener>
  • Listens to when a message is deleted by a recipient or the host account

    fires

    Message

    Parameters

    • fn: (message: Message) => void

      callback

    Returns Promise<boolean | Listener>

onParticipantsChanged

  • onParticipantsChanged(groupId: `${number}-${number}@g.us`, fn: (participantChangedEvent: ParticipantChangedEventModel) => void, legacy?: boolean): Promise<boolean | Listener>

onPlugged

  • onPlugged(fn: (plugged: boolean) => void): Promise<boolean | Listener>
  • Listens to when host device is plugged/unplugged

    fires

    boolean true if plugged, false if unplugged

    Parameters

    • fn: (plugged: boolean) => void

      callback

        • (plugged: boolean): void
        • Parameters

          • plugged: boolean

          Returns void

    Returns Promise<boolean | Listener>

onRemovedFromGroup

  • onRemovedFromGroup(fn: (chat: Chat) => any): Promise<boolean | Listener>
  • Fires callback with Chat object every time the host phone is removed to a group.

    Parameters

    • fn: (chat: Chat) => any

      callback function that handles a Chat (group chat) as the first and only parameter.

        • Parameters

          Returns any

    Returns Promise<boolean | Listener>

    true if the callback was registered

onStateChanged

  • onStateChanged(fn: (state: STATE) => void): Promise<boolean | Listener>
  • Listens to changes in state

    fires

    STATE observable sream of states

    Parameters

    • fn: (state: STATE) => void
        • Parameters

          Returns void

    Returns Promise<boolean | Listener>

onStory

  • onStory(fn: (story: Message) => void): 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

    Returns Promise<boolean | Listener>

Methods

B

  • B(chatId: ChatId, payload: {}): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Use a Baileys payload within your open-wa session

    Parameters

    • chatId: ChatId
    • payload: {}

      returns: MessageId

      • [k: string]: any

    Returns Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

addLabel

  • addLabel(label: string, chatId: ChatId): Promise<boolean>
  • Adds label from chat, message or contact. Only for business accounts.

    Parameters

    • label: string
    • chatId: ChatId

    Returns Promise<boolean>

addParticipant

  • addParticipant(groupId: `${number}-${number}@g.us`, participantId: `${number}@c.us` | `${number}@c.us`[]): 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

    Returns Promise<boolean>

archiveChat

  • archiveChat(id: ChatId, archive: boolean): Promise<boolean>
  • Parameters

    • id: ChatId

      The id of the conversation

    • archive: boolean

      boolean true => archive, false => unarchive

    Returns Promise<boolean>

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

autoReject

  • autoReject(message?: string): Promise<boolean>
  • Automatically reject calls on the host account device. Please note that the device that is calling you will continue to ring.

    Parameters

    • Optional message: string

      optional message to send to the calling account when their call is detected and rejected

    Returns Promise<boolean>

awaitMessages

  • [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

    Returns Promise<Collection<string, Message>>

checkNumberStatus

  • checkNumberStatus(contactId: `${number}@c.us`): Promise<NumberCheck>
  • Checks if a number is a valid WA number

    Parameters

    • contactId: `${number}@c.us`

    Returns Promise<NumberCheck>

checkReadReceipts

  • checkReadReceipts(contactId: `${number}@c.us`): Promise<string | boolean>
  • 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

    • contactId: `${number}@c.us`

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

    • Optional ts: number

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

    Returns Promise<boolean>

clearChat

  • clearChat(chatId: ChatId): Promise<boolean>
  • Delete all messages from the chat.

    Parameters

    Returns Promise<boolean>

    boolean

contactBlock

  • contactBlock(id: `${number}@c.us`): Promise<boolean>
  • Block contact

    Parameters

    Returns Promise<boolean>

contactUnblock

  • contactUnblock(id: `${number}@c.us`): Promise<boolean>
  • Unblock contact

    Parameters

    Returns Promise<boolean>

createGroup

  • Create a group and add contacts to it

    Parameters

    • groupName: string

      group name: 'New group'

    • contacts: `${number}@c.us` | `${number}@c.us`[]

    Returns Promise<GroupChatCreationResponse>

    Promise :

    {
      status: 200,
      gid: {
        server: 'g.us',
        user: '447777777777-1583678870',
        _serialized: '447777777777-1583678870@g.us'
      },
      participants: [
        { '447777777777@c.us': [Object] },
        { '447444444444@c.us': [Object] }
      ]
    }
    

createLabel

  • createLabel(label: string): Promise<string | boolean>
  • Adds label from chat, message or contact. Only for business accounts.

    Parameters

    • label: string

    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

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

    Parameters

    • c: Message | Chat | ChatId

      The Mesasge/Chat or Chat Id to base this message colletor on

    • filter: CollectorFilter<[Message]>

      A function that consumes a [Message] and returns a boolean which determines whether or not the message shall be collected.

    • options: CollectorOptions

      The 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

  • createNewProduct(name: string, price: number, currency: string, images: string[], description: string, url?: string, internalId?: string, isHidden?: boolean): Promise<Product>
  • Add a product to your catalog

    Parameters

    • name: string

      The name of the product

    • price: number

      The price of the product

    • currency: string

      The 3-letter currenct code for the product

    • images: string[]

      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: string

      optional, the description of the product

    • Optional url: string

      The url of the product for more information

    • Optional internalId: string

      The internal/backoffice id of the product

    • Optional isHidden: boolean

      Whether 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: boolean): Promise<boolean>
  • Start dark mode [NOW GENERALLY AVAILABLE]

    Parameters

    • activate: boolean

      true to activate dark mode, false to deactivate

    Returns Promise<boolean>

decryptMedia

  • decryptMedia(message: Message | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<string>
  • Decrypts a media message.

    Parameters

    • message: Message | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      This can be the serialized MessageId or the whole Message object. It is advised to just use the serialized message ID.

    Returns Promise<string>

    Promise<DataURL>

deleteAllStatus

  • deleteAllStatus(): Promise<boolean>
  • Deletes all your existing statuses.

    Returns Promise<boolean>

    boolean. True if it worked.

deleteChat

  • deleteChat(chatId: ChatId): Promise<boolean>
  • Delete the conversation from your WA

    Parameters

    Returns Promise<boolean>

    boolean

deleteMessage

  • deleteMessage(chatId: ChatId, messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}` | (`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`)[], onlyLocal?: boolean): Promise<void>
  • Deletes message of given message id

    Parameters

    • chatId: ChatId

      The chat id from which to delete the message.

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}` | (`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`)[]

      The specific message id of the message to be deleted

    • onlyLocal: boolean = false

      If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.

    Returns Promise<void>

    nothing

deleteStaleChats

  • deleteStaleChats(startingFrom?: number): 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

    • Optional startingFrom: number

      the chat index to start from. Please do not set this to anything less than 10 @default: 1000

    Returns Promise<boolean>

deleteStatus

  • deleteStatus(statusesToDelete: string | string[]): Promise<boolean>
  • Consumes a list of id strings of statuses to delete.

    Parameters

    • statusesToDelete: string | string[]

      string [] | stringan array of ids of statuses to delete.

    Returns Promise<boolean>

    boolean. True if it worked.

demoteParticipant

  • demoteParticipant(groupId: `${number}-${number}@g.us`, participantId: `${number}@c.us` | `${number}@c.us`[]): 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

    Returns Promise<boolean>

download

  • download(url: string, optionsOverride?: any): Promise<string>
  • A convinience method to download the DataURL of a file

    Parameters

    • url: string

      The url

    • optionsOverride: any = {}

      You can use this to override the axios request config

    Returns Promise<string>

    Promise

downloadFileWithCredentials

  • downloadFileWithCredentials(url: string): Promise<string>
  • Download via the browsers authenticated session via URL.

    Parameters

    • url: string

    Returns Promise<string>

    base64 string (non-data url)

downloadProfilePicFromMessage

  • downloadProfilePicFromMessage(message: Message): Promise<string>
  • 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

    Returns Promise<string>

editProduct

  • editProduct(productId: string, name?: string, price?: number, currency?: string, images?: string[], description?: string, url?: string, internalId?: string, isHidden?: boolean): Promise<Product>
  • Edit a product in your catalog

    Parameters

    • productId: string

      The catalog ID of the product

    • Optional name: string

      The name of the product

    • Optional price: number

      The price of the product

    • Optional currency: string

      The 3-letter currenct code for the product

    • Optional images: string[]

      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.

    • Optional description: string

      optional, the description of the product

    • Optional url: string

      The url of the product for more information

    • Optional internalId: string

      The internal/backoffice id of the product

    • Optional isHidden: boolean

      Whether or not the product is shown publicly in your catalog

    Returns Promise<Product>

    product object

forceRefocus

  • forceRefocus(): Promise<void>
  • 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<void>

forceStaleMediaUpdate

  • forceStaleMediaUpdate(messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<false | Message>
  • 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

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

    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

  • 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

    • chatId: ChatId

      string 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: ChatId, messages: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}` | (`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`)[], skipMyMessages: boolean): Promise<string | boolean>
  • Forward an array of messages to a specific chat using the message ids or Objects

    Parameters

    • to: ChatId
    • messages: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}` | (`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`)[]

      this can be any mixture of message ids or message objects

    • skipMyMessages: boolean

      This indicates whether or not to skip your own messages from the array

    Returns Promise<string | boolean>

getAllChatIds

  • getAllChatIds(): Promise<ChatId[]>
  • retrieves all Chat Ids

    Returns Promise<ChatId[]>

    array of [ChatId]

getAllChats

  • getAllChats(withNewMessageOnly?: boolean): Promise<Chat[]>
  • Retrieves all chats

    Parameters

    • withNewMessageOnly: boolean = false

    Returns Promise<Chat[]>

    array of [Chat]

getAllChatsWithMessages

  • getAllChatsWithMessages(withNewMessageOnly?: boolean): 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

    • withNewMessageOnly: boolean = false

    Returns Promise<Chat[]>

    array of [Chat]

getAllContacts

  • getAllContacts(): Promise<Contact[]>
  • Retrieves all contacts

    Returns Promise<Contact[]>

    array of [Contact]

getAllGroups

  • getAllGroups(withNewMessagesOnly?: boolean): Promise<Chat[]>
  • Retrieve all groups

    Parameters

    • withNewMessagesOnly: boolean = false

    Returns Promise<Chat[]>

    array of groups

getAllLabels

  • getAllLabels(): Promise<Label[]>
  • Returns all labels and the corresponding tagged items.

    Returns Promise<Label[]>

getAllMessagesInChat

  • getAllMessagesInChat(chatId: ChatId, includeMe: boolean, includeNotifications: boolean): 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

    • chatId: ChatId
    • includeMe: boolean
    • includeNotifications: boolean

    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: `${number}@c.us`): Promise<any>
  • Find any product listings of the given number. Use this to query a catalog

    Parameters

    • id: `${number}@c.us`

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

    Returns Promise<any>

    None

getChat

  • getChat(contactId: `${number}@c.us`): Promise<Chat>
  • Retrieves chat object of given contact id

    Parameters

    • contactId: `${number}@c.us`

    Returns Promise<Chat>

    contact detial as promise

getChatById

  • getChatById(contactId: `${number}@c.us`): Promise<Chat>
  • Retrieves chat object of given contact id

    Parameters

    • contactId: `${number}@c.us`

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

    • label: string

    Returns Promise<Chat[]>

getCommonGroups

  • getCommonGroups(contactId: `${number}@c.us`): Promise<{ id: string; title: string }[]>
  • Retrieves the groups that you have in common with a contact

    Parameters

    • contactId: `${number}@c.us`

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

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

getConfig

  • 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: `${number}@c.us`): Promise<Contact>
  • Retrieves contact detail object of given contact id

    Parameters

    • contactId: `${number}@c.us`

    Returns Promise<Contact>

    contact detial as promise

getEventSignature

getGeneratedUserAgent

  • getGeneratedUserAgent(userA?: string): Promise<string>
  • Get the generated user agent, this is so you can send it to the decryption module.

    Parameters

    • Optional userA: string

    Returns Promise<string>

    String useragent of wa-web session

getGroupAdmins

  • getGroupAdmins(groupId: `${number}-${number}@g.us`): Promise<`${number}@c.us`[]>
  • Get Admins of a Group

    Parameters

    Returns Promise<`${number}@c.us`[]>

getGroupInfo

  • getGroupInfo(groupId: `${number}-${number}@g.us`): Promise<any>
  • Returns the title and description of a given group id.

    Parameters

    • groupId: `${number}-${number}@g.us`

      group id

    Returns Promise<any>

getGroupInviteLink

  • getGroupInviteLink(chatId: ChatId): Promise<string>
  • Retrieves an invite link for a group chat. returns false if chat is not a group.

    Parameters

    Returns Promise<string>

    Promise

getGroupMembers

  • getGroupMembers(groupId: `${number}-${number}@g.us`): Promise<Contact[]>
  • Returns group members [Contact] objects

    Parameters

    • groupId: `${number}-${number}@g.us`

    Returns Promise<Contact[]>

getGroupMembersId

  • getGroupMembersId(groupId: `${number}-${number}@g.us`): Promise<`${number}@c.us`[]>
  • Retrieves group members as [Id] objects

    Parameters

    • groupId: `${number}-${number}@g.us`

      group id

    Returns Promise<`${number}@c.us`[]>

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

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

    • chatId: ChatId

      The id of the chat.

    Returns Promise<number | boolean>

    number timestamp when chat was last online or undefined.

getLicenseType

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

    Returns Promise<false | LicenseType>

getListenerQueues

  • getListenerQueues(): { onAck: any; onAddedToGroup: any; onAnyMessage: any; onBattery: any; onButton: any; onChatDeleted: any; onChatOpened: any; onChatState: any; onContactAdded: any; onGlobalParticipantsChanged: any; onIncomingCall: any; onLogout: any; onMessage: any; onMessageDeleted: any; onOrder: any; onPlugged: any; onRemovedFromGroup: any; onStateChanged: any; onStory: any }
  • If you have set onAnyMessage or onMessage with the second parameter (PQueue options) then you may want to inspect their respective PQueue's.

    Returns { onAck: any; onAddedToGroup: any; onAnyMessage: any; onBattery: any; onButton: any; onChatDeleted: any; onChatOpened: any; onChatState: any; onContactAdded: any; onGlobalParticipantsChanged: any; onIncomingCall: any; onLogout: any; onMessage: any; onMessageDeleted: any; onOrder: any; onPlugged: any; onRemovedFromGroup: any; onStateChanged: any; onStory: any }

    • onAck:
    • onAddedToGroup:
    • onAnyMessage:
    • onBattery:
    • onButton:
    • onChatDeleted:
    • onChatOpened:
    • onChatState:
    • onContactAdded:
    • onGlobalParticipantsChanged:
    • onIncomingCall:
    • onLogout:
    • onMessage:
    • onMessageDeleted:
    • onOrder:
    • onPlugged:
    • onRemovedFromGroup:
    • onStateChanged:
    • onStory:

getMe

  • getMe(): Promise<any>
  • Returns an object with all of your host device details

    Returns Promise<any>

getMessageById

  • getMessageById(messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<Message>
  • Retrieves message object of given message id

    Parameters

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

    Returns Promise<Message>

    message object

getMessageReaders

  • getMessageReaders(messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): 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

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      The message id

    Returns Promise<Contact[]>

getMyLastMessage

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

    Parameters

    • Optional chatId: ChatId

      This 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

getMyStatusArray

  • getMyStatusArray(): Promise<Message[]>
  • retrieves all existing statuses.

    Only works with a Story License Key

    Returns Promise<Message[]>

getOrder

  • getOrder(id: string | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<Order>
  • Retrieves an order object

    Parameters

    • id: string | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

    Returns Promise<Order>

    order object

getPage

  • getPage(): Page
  • Returns Page

getProfilePicFromServer

  • getProfilePicFromServer(chatId: ChatId): Promise<string>
  • Retrieves chat picture

    Parameters

    Returns Promise<string>

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

getSessionId

  • getSessionId(): string
  • Returns string

getSessionInfo

getSingleProperty

  • getSingleProperty(namespace: namespace, id: string, property: string): 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

    • namespace: namespace
    • id: string

      id of the object to get from the specific namespace

    • property: string

      the 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(): Promise<string>
  • Returns a PNG DataURL screenshot of the session

    Returns Promise<string>

    Promise

getStatus

  • getStatus(contactId: `${number}@c.us`): Promise<{ id: string; status: string }>
  • Get the status of a contact

    Parameters

    • contactId: `${number}@c.us`

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

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

getStickerDecryptable

  • getStickerDecryptable(messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<boolean | Message>
  • 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

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      The message ID message.id

    Returns Promise<boolean | Message>

    message object OR false

getStoryViewers

  • getStoryViewers(id: string): Promise<`${number}@c.us`[]>
  • Retrieves an array of user ids that have 'read' your story.

    Parameters

    • id: string

      string The id of the story

      Only works with a Story License Key

    Returns Promise<`${number}@c.us`[]>

getUnreadMessages

  • getUnreadMessages(includeMe: boolean, includeNotifications: boolean, use_unread_count: boolean): Promise<Message[]>
  • Retrieves all undread Messages

    Parameters

    • includeMe: boolean
    • includeNotifications: boolean
    • use_unread_count: boolean

    Returns Promise<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: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<string[]>
  • Extracts vcards from a message.This works on messages of typ vcard or multi_vcard

    Parameters

    • msgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string id of the message to extract the vcards from

    Returns Promise<string[]>

    [
    {
    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: ChatId, messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId
    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    Promise<MessageId | boolean>

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<`${number}-${number}@g.us`[]>
  • Returns an array of group ids where the host device is admin

    Returns Promise<`${number}-${number}@g.us`[]>

inviteInfo

  • inviteInfo(link: string): Promise<any>
  • Get the details of a group through the invite link

    Parameters

    • link: string

      This can be an invite link or invite code

    Returns Promise<any>

isChatMuted

  • isChatMuted(chatId: ChatId): Promise<boolean>
  • Checks if a chat is muted

    Parameters

    • chatId: ChatId

      The id of the chat you want to check

    Returns Promise<boolean>

    boolean. false if the chat does not exist.

isChatOnline

  • isChatOnline(chatId: 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

    • chatId: ChatId

      chat 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

  • isGroupIdUnsafe(groupChatId: `${number}-${number}@g.us`): Promise<string | boolean>
  • Checks whether or not the group id provided is known to be unsafe by the contributors of the library.

    Parameters

    • groupChatId: `${number}-${number}@g.us`

      The 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

  • joinGroupViaLink(link: string, returnChatObj?: boolean): Promise<string | number | boolean | Chat>
  • Joins a group via the invite link, code, or message

    Parameters

    • link: string

      This param is the string which includes the invite link or code. The following work:

      If you have been removed from the group previously, it will return 401

    • Optional returnChatObj: boolean

      boolean 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(): Promise<boolean>
  • Shuts down the page and browser

    Returns Promise<boolean>

    true

leaveGroup

  • leaveGroup(groupId: `${number}-${number}@g.us`): Promise<boolean>
  • Removes the host device from the group

    Parameters

    • groupId: `${number}-${number}@g.us`

      group id

    Returns Promise<boolean>

listWebhooks

  • listWebhooks(): Promise<Webhook[]>
  • Retreives an array of webhook objects

    Returns Promise<Webhook[]>

loadAllEarlierMessages

  • loadAllEarlierMessages(contactId: `${number}@c.us`): Promise<Message[]>
  • Load all messages in chat object from server.

    Parameters

    • contactId: `${number}@c.us`

    Returns Promise<Message[]>

    Message[]

loadAndGetAllMessagesInChat

  • loadAndGetAllMessagesInChat(chatId: ChatId, includeMe: boolean, includeNotifications: boolean): Promise<Message[]>
  • loads and Retrieves all Messages in a chat

    Parameters

    • chatId: ChatId
    • includeMe: boolean
    • includeNotifications: boolean

    Returns Promise<Message[]>

    any

loadEarlierMessages

  • loadEarlierMessages(contactId: `${number}@c.us`): 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

    • contactId: `${number}@c.us`

    Returns Promise<Message[]>

    Message []

loadEarlierMessagesTillDate

  • loadEarlierMessagesTillDate(contactId: `${number}@c.us`, timestamp: number): Promise<Message[]>
  • Load all messages until a given timestamp in chat object from server.

    Parameters

    • contactId: `${number}@c.us`
    • timestamp: number

      in seconds

    Returns Promise<Message[]>

    Message[]

logger

  • logger(): any
  • Grab the logger for this session/process

    Returns any

markAsUnread

  • markAsUnread(chatId: ChatId): Promise<boolean>
  • Sets a chat status to unread. May be useful to get host's attention

    Parameters

    • chatId: ChatId

      chat id: xxxxx@c.us

    Returns Promise<boolean>

middleware

  • middleware(useSessionIdInPath?: boolean): (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

    • useSessionIdInPath: boolean = false

      boolean 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 (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => Promise<any>

      • (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction): Promise<any>
      • Parameters

        • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
        • res: Response<any, Record<string, any>>
        • next: NextFunction

        Returns Promise<any>

muteChat

  • 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

    • chatId: ChatId

      The id of the conversation you want to mute

    • muteDuration: ChatMuteDuration

      ChatMuteDuration 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

onOrder

  • onOrder(fn: (order: Order) => void): Promise<boolean | Listener>

pinChat

  • pinChat(id: ChatId, pin: boolean): Promise<boolean>
  • Pin/Unpin chats

    Parameters

    • id: ChatId

      The id of the conversation

    • pin: boolean

    Returns Promise<boolean>

    boolean true: worked

postImageStatus

  • postImageStatus(data: string, caption: string): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Posts an image story.

    Parameters

    • data: string

      data url string data:[<MIME-type>][;charset=<encoding>][;base64],<data>

    • caption: string

      The caption for the story

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

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

postTextStatus

  • postTextStatus(text: string, textRgba: string, backgroundRgba: string, font: number): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a formatted text story.

    Parameters

    • text: string

      The text to be displayed in the story

    • textRgba: string

      The colour of the text in the story in hex format, make sure to add the alpha value also. E.g "#FF00F4F2"

    • backgroundRgba: string

      The colour of the background in the story in hex format, make sure to add the alpha value also. E.g "#4FF31FF2"

    • font: number

      The 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 | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

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

postVideoStatus

  • postVideoStatus(data: string, caption: string): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Posts a video story.

    Parameters

    • data: string

      data url string data:[<MIME-type>][;charset=<encoding>][;base64],<data>

    • caption: string

      The caption for the story

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

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

prepEventData

promoteParticipant

  • promoteParticipant(groupId: `${number}-${number}@g.us`, participantId: `${number}@c.us` | `${number}@c.us`[]): 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

    Returns Promise<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: string, events: SimpleListener[] | "all", requestConfig?: AxiosRequestConfig, concurrency?: number): Promise<false | Webhook>
  • The client can now automatically handle webhooks. Use this method to register webhooks.

    Parameters

    • url: string

      The webhook url

    • events: SimpleListener[] | "all"

      An array of SimpleListener enums or all (to register all possible listeners)

    • requestConfig: AxiosRequestConfig = {}

      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

    • concurrency: number = 5

      the 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: string, chatId: ChatId): Promise<boolean>
  • Removes label from chat, message or contact. Only for business accounts.

    Parameters

    • label: string
    • chatId: ChatId

    Returns Promise<boolean>

removeListener

  • //////////////////////// LISTENERS

    Parameters

    Returns boolean

removeParticipant

  • removeParticipant(groupId: `${number}-${number}@g.us`, participantId: `${number}@c.us`): 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

    • groupId: `${number}-${number}@g.us`

      0000000000-00000000@g.us

    • participantId: `${number}@c.us`

      000000000000@c.us

    Returns Promise<boolean>

removeProduct

  • removeProduct(productId: string): Promise<boolean>
  • Remove a product from the host account's catalog

    Parameters

    • productId: string

      The id of the product

    Returns Promise<boolean>

    boolean

removeWebhook

  • removeWebhook(webhookId: string): 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

    • webhookId: string

      The ID of the webhook

    Returns Promise<boolean>

reply

  • reply(to: ChatId, content: string, quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, sendSeen?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId

      string chatid

    • content: string

      string reply text

    • quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string the msg id to reply to.

    • Optional sendSeen: boolean

      boolean If set to true, the chat will 'blue tick' all messages before sending the reply

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

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

reportSpam

  • reportSpam(id: ChatId): Promise<boolean>

revokeGroupInviteLink

  • revokeGroupInviteLink(chatId: ChatId): Promise<string | boolean>
  • Revokes the current invite link for a group chat. Any previous links will stop working

    Parameters

    Returns Promise<string | boolean>

    Promise

sendAudio

  • sendAudio(to: ChatId, file: string, quotedMsgId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send an audio file with the default audio player (not PTT/voice message)

    Parameters

    • to: ChatId

      chat id xxxxx@c.us

    • file: string
    • Optional quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

    Returns Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendBanner

  • sendBanner(to: ChatId, base64: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId
    • base64: string

      base64 encoded jpeg

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendButtons

  • sendButtons(to: ChatId, body: string, buttons: Button[], title: string, footer?: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send generic quick reply buttons

    Parameters

    • to: ChatId

      chat id

    • body: string

      The body of the buttons message

    • buttons: Button[]

      Array of buttons - limit is 3!

    • title: string

      The title/header of the buttons message

    • Optional footer: string

      The footer of the buttons message

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendContact

  • sendContact(to: ChatId, contactId: `${number}@c.us` | `${number}@c.us`[]): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendCustomProduct

  • sendCustomProduct(to: ChatId, image: string, productData: CustomProduct): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendEmoji

  • sendEmoji(to: ChatId, emojiId: string, messageId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send a discord emoji to a chat as a sticker

    Parameters

    • to: ChatId

      ChatId The chat id you want to send the webp sticker to

    • emojiId: string

      The discord emoji id without indentifying chars. In discord you would write :who:, here use who

    • Optional messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      message id of the message you want this sticker to reply to. REQUIRES AN INSIDERS LICENSE-KEY

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendFile

  • sendFile(to: ChatId, file: string, filename: string, caption: string, quotedMsgId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId

      chat id xxxxx@c.us

    • file: string

      DataURL 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).

    • filename: string

      string xxxxx

    • caption: string

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

    • Optional quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

    • Optional waitForId: boolean

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

    • Optional ptt: boolean

      boolean default: false set this to true if you want to send the file as a push to talk file.

    • Optional withoutPreview: boolean

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

    • Optional hideTags: boolean

      boolean default: false [INSIDERS] set this to try silent tag someone in the caption

    • Optional viewOnce: boolean

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    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: ChatId, url: string, filename: string, caption: string, quotedMsgId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, requestConfig?: AxiosRequestConfig, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a file by Url or custom options

    Parameters

    • to: ChatId

      chat id xxxxx@c.us

    • url: string
    • filename: string

      string 'video.mp4'

    • caption: string

      string xxxxx

    • Optional quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

    • requestConfig: AxiosRequestConfig = {}

      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

    • Optional waitForId: boolean

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

    • Optional ptt: boolean

      boolean default: false set this to true if you want to send the file as a push to talk file.

    • Optional withoutPreview: boolean

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

    • Optional hideTags: boolean
    • Optional viewOnce: boolean

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendGiphy

  • sendGiphy(to: ChatId, giphyMediaUrl: string, caption: string): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendGiphyAsSticker

  • sendGiphyAsSticker(to: ChatId, giphyMediaUrl: string | URL): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send a giphy GIF as an animated sticker.

    Parameters

    • to: ChatId

      ChatId

    • giphyMediaUrl: string | URL

      URL | 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 | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendImage

  • sendImage(to: ChatId, file: string, filename: string, caption: string, quotedMsgId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a image to given chat, with caption or not, using base64

    Parameters

    • to: ChatId

      chat id xxxxx@c.us

    • file: string

      DataURL 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).

    • filename: string

      string xxxxx

    • caption: string

      string xxxxx

    • Optional quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`
    • Optional waitForId: boolean
    • Optional ptt: boolean
    • Optional withoutPreview: boolean
    • Optional hideTags: boolean

      boolean default: false [INSIDERS] set this to try silent tag someone in the caption

    • Optional viewOnce: boolean

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    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: ChatId, image: string | Buffer, stickerMetadata?: StickerMetadata): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendImageAsStickerAsReply

  • sendImageAsStickerAsReply(to: ChatId, image: string | Buffer, messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, stickerMetadata?: StickerMetadata): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • This function takes an image and sends it as a sticker to the recipient as a reply to another message.

    Parameters

    • to: ChatId

      The recipient id.

    • image: string | Buffer
    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      The id of the message to reply to

    • Optional stickerMetadata: StickerMetadata

      Sticker metadata

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendImageWithProduct

  • sendImageWithProduct(to: ChatId, image: string, caption: string, bizNumber: `${number}@c.us`, productId: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends product with image to chat

    Parameters

    • to: ChatId
    • image: string
    • caption: string

      string the caption you want to add to this message

    • bizNumber: `${number}@c.us`

      string the @c.us number of the business account from which you want to grab the product

    • productId: string

      string the id of the product within the main catalog of the aforementioned business

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendLinkWithAutoPreview

  • sendLinkWithAutoPreview(to: ChatId, url: string, text?: string, thumbnail?: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Automatically sends a link with the auto generated link preview. You can also add a custom message.

    Parameters

    • to: ChatId
    • url: string

      string A link.

    • Optional text: string

      string Custom text as body of the message, this needs to include the link or it will be appended after the link.

    • Optional thumbnail: string

      Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendListMessage

  • sendListMessage(to: ChatId, sections: Section[], title: string, description: string, actionText: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send a list message. This will not work when being sent from business accounts!

    Parameters

    • to: ChatId
    • sections: Section[]

      The Sections of rows for the list message

    • title: string

      The title of the list message

    • description: string

      The description of the list message

    • actionText: string

      The action text of the list message

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendLocation

  • sendLocation(to: ChatId, lat: string, lng: string, loc: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a location message to given chat

    Parameters

    • to: ChatId

      chat id: xxxxx@c.us

    • lat: string

      latitude: '51.5074'

    • lng: string

      longitude: '0.1278'

    • loc: string

      location text: 'LONDON!'

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendMessageWithThumb

  • sendMessageWithThumb(thumb: string, url: string, title: string, description: string, text: string, chatId: ChatId): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • deprecated

    Use sendLinkWithAutoPreview instead Sends a link to a chat that includes a link preview.

    Parameters

    • thumb: string

      The 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

    • url: string

      The link you want to send

    • title: string

      The title of the link

    • description: string

      The long description of the link preview

    • text: string

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

    • chatId: ChatId

      The chat you want to send this message to.

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendMp4AsSticker

  • sendMp4AsSticker(to: ChatId, file: string | Buffer, processOptions?: Mp4StickerConversionProcessOptions, stickerMetadata?: StickerMetadata, messageId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId

      ChatId The chat id you want to send the webp sticker to

    • file: string | Buffer

      DataURL, Base64, URL (string GET), Relative filepath (string), or Buffer of the mp4 file

    • processOptions: Mp4StickerConversionProcessOptions = ...
    • Optional stickerMetadata: StickerMetadata
    • Optional messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      message id of the message you want this sticker to reply to. REQUIRES AN INSIDERS LICENSE-KEY

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendMultipleContacts

  • sendMultipleContacts(to: ChatId, contactIds: `${number}@c.us`[]): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends multiple contacts as a single message

    Parameters

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendPaymentRequest

  • sendPaymentRequest(to: ChatId, amount: number, currency: string, message?: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • [UNTESTED - REQUIRES FEEDBACK] Sends a payment request message to given chat

    Parameters

    • to: ChatId

      chat id: xxxxx@c.us

    • amount: number

      number the amount to request in 1000 format (e.g £10 => 10000)

    • currency: string

      string The 3 letter currency code

    • Optional message: string

      string optional message to send with the payment request

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendProduct

  • sendProduct(chatId: ChatId, productId: string): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Send a product to a chat

    Parameters

    • chatId: ChatId

      The chatId

    • productId: string

      The id of the product

    Returns Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    MessageID

sendPtt

  • sendPtt(to: ChatId, file: string, quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Attempts to send a file as a voice note. Useful if you want to send an mp3 file.

    Parameters

    • to: ChatId

      chat id xxxxx@c.us

    • file: string

      base64 data:image/xxx;base64,xxx or the path of the file you want to send.

    • quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

    Returns Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    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: ChatId, webpBase64: string, animated?: boolean): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • You can use this to send a raw webp file.

    Parameters

    • to: ChatId

      ChatId The chat id you want to send the webp sticker to

    • webpBase64: string

      Base64 The base64 string of the webp file. Not DataURl

    • animated: boolean = false

      Boolean Set to true if the webp is animated. Default false

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendRawWebpAsStickerAsReply

  • sendRawWebpAsStickerAsReply(to: ChatId, messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, webpBase64: string, animated?: boolean): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • You can use this to send a raw webp file.

    Parameters

    • to: ChatId

      ChatId The chat id you want to send the webp sticker to

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      MessageId Message ID of the message to reply to

    • webpBase64: string

      Base64 The base64 string of the webp file. Not DataURl

    • animated: boolean = false

      Boolean Set to true if the webp is animated. Default false

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendReplyWithMentions

  • sendReplyWithMentions(to: ChatId, content: string, replyMessageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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

    • to: ChatId

      chat id: xxxxx@c.us

    • content: string

      text message

    • replyMessageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      id of message to reply to

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendSeen

  • sendSeen(chatId: ChatId): Promise<boolean>
  • Sets a chat status to seen. Marks all messages as ack: 3

    Parameters

    • chatId: ChatId

      chat id: xxxxx@c.us

    Returns Promise<boolean>

sendStickerfromUrl

  • sendStickerfromUrl(to: ChatId, url: string, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a sticker (including GIF) from a given URL

    Parameters

    Returns Promise<string | boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    Promise<MessageId | boolean>

sendStickerfromUrlAsReply

  • sendStickerfromUrlAsReply(to: ChatId, url: string, messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a sticker from a given URL

    Parameters

    • to: ChatId

      The recipient id.

    • url: string

      The url of the image

    • messageId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      The id of the message to reply to

    • requestConfig: AxiosRequestConfig = {}

      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

    • Optional stickerMetadata: StickerMetadata

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    Promise<MessageId | boolean>

sendText

  • sendText(to: ChatId, content: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a text message to given chat If you need to send a message to new numbers please see these instructions:

    Parameters

    • to: ChatId

      chat id: xxxxx@c.us

    • content: string

      text message

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendTextWithMentions

  • sendTextWithMentions(to: ChatId, content: string, hideTags?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • 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.

    Please note that the hideTag parameter only works with an Insider's License Key

    Parameters

    • to: ChatId

      chat id: xxxxx@c.us

    • content: string

      text message

    • Optional hideTags: boolean

      Removes all tags within the message

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendVCard

  • sendVCard(chatId: ChatId, vcard: string, contactName: string, contactNumber?: string): Promise<boolean>
  • Send VCARD

    Parameters

    • chatId: ChatId
    • vcard: string

      vcard as a string

    • contactName: string

      The display name for the contact. CANNOT BE NULL OTHERWISE IT WILL SEND SOME RANDOM CONTACT FROM YOUR ADDRESS BOOK.

    • Optional contactNumber: string

      If 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

    Returns Promise<boolean>

sendVideoAsGif

  • sendVideoAsGif(to: ChatId, file: string, filename: string, caption: string, quotedMsgId?: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`, requestConfig?: AxiosRequestConfig): Promise<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Sends a video to given chat as a gif, with caption or not, using base64

    Parameters

    • to: ChatId

      chat id xxxxx@c.us

    • file: string

      DataURL 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).

    • filename: string

      string xxxxx

    • caption: string

      string xxxxx

    • Optional quotedMsgId: `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`

      string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message

    • requestConfig: AxiosRequestConfig = {}

      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<`false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

sendYoutubeLink

  • sendYoutubeLink(to: ChatId, url: string, text?: string, thumbnail?: string): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Automatically sends a youtube link with the auto generated link preview. You can also add a custom message.

    Parameters

    • to: ChatId
    • url: string

      string A youtube link.

    • text: string = ''

      string Custom text as body of the message, this needs to include the link or it will be appended after the link.

    • Optional thumbnail: string

      string Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

setChatBackgroundColourHex

  • setChatBackgroundColourHex(hex: string): Promise<boolean>

setChatEphemeral

  • setChatEphemeral(chatId: ChatId, ephemeral: boolean): Promise<boolean>
  • Turn the ephemeral setting in a chat to on or off

    Parameters

    • chatId: ChatId

      The ID of the chat

    • ephemeral: boolean

      true to turn on the ephemeral setting, false to turn off the ephemeral setting. Please note, if the setting is already on the requested setting, this method will return true.

    Returns Promise<boolean>

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

setChatState

  • Sets the chat state

    Parameters

    • chatState: ChatState

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

    • chatId: ChatId

    Returns Promise<boolean>

setGroupDescription

  • setGroupDescription(groupId: `${number}-${number}@g.us`, description: string): Promise<boolean>
  • Change the group chant description

    Parameters

    • groupId: `${number}-${number}@g.us`

      '0000000000-00000000@g.us' the group id.

    • description: string

      string The new group description

    Returns Promise<boolean>

    boolean true if action completed successfully.

setGroupEditToAdminsOnly

  • setGroupEditToAdminsOnly(groupId: `${number}-${number}@g.us`, onlyAdmins: boolean): Promise<boolean>
  • Change who can and cannot edit a groups details

    Parameters

    • groupId: `${number}-${number}@g.us`

      '0000000000-00000000@g.us' the group id.

    • onlyAdmins: boolean

      boolean 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: `${number}-${number}@g.us`, image: string): Promise<boolean>
  • Change the icon for the group chat

    Parameters

    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: `${number}-${number}@g.us`, url: string, requestConfig?: AxiosRequestConfig): Promise<boolean>
  • Change the icon for the group chat

    Parameters

    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

  • setGroupTitle(groupId: `${number}-${number}@g.us`, title: string): Promise<boolean>

setGroupToAdminsOnly

  • setGroupToAdminsOnly(groupId: `${number}-${number}@g.us`, onlyAdmins: boolean): Promise<boolean>
  • Change who can and cannot speak in a group

    Parameters

    • groupId: `${number}-${number}@g.us`

      '0000000000-00000000@g.us' the group id.

    • onlyAdmins: boolean

      boolean 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: string): Promise<boolean>
  • Set your profile name

    Please note, this does not work on business accounts!

    Parameters

    • newName: string

      String new name to set for your profile

    Returns Promise<boolean>

setMyStatus

  • setMyStatus(newStatus: string): Promise<boolean | void>
  • set your about me

    Parameters

    • newStatus: string

      String new profile status

    Returns Promise<boolean | void>

setPresence

  • setPresence(available: boolean): Promise<boolean | void>
  • Set presence to available or unavailable.

    Parameters

    • available: boolean

      if 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: string): Promise<boolean>
  • Sets the profile pic of the host number.

    Parameters

    • data: string

      string data url image string.

    Returns Promise<boolean>

    Promise success if true

simulateTyping

  • simulateTyping(to: ChatId, on: boolean): Promise<boolean>
  • Simulate '...typing' in chat

    Parameters

    • to: ChatId
    • on: boolean

      turn on similated typing, false to turn it off you need to manually turn this off.

    Returns Promise<boolean>

syncContacts

  • syncContacts(): Promise<boolean>
  • Syncs contacts with phone. This promise does not resolve so it will instantly return true.

    Returns Promise<boolean>

tagEveryone

  • tagEveryone(groupId: `${number}-${number}@g.us`, content: string, hideTags?: boolean): Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>
  • Tags everyone in the group with a message

    Parameters

    • groupId: `${number}-${number}@g.us`

      group chat id: xxxxx@g.us

    • content: string

      text message to add under all of the tags

    • Optional hideTags: boolean

      Removes all tags within the message

    Returns Promise<boolean | `false_${number}-${number}@g.us_${string}` | `false_${number}@c.us_${string}` | `true_${number}-${number}@g.us_${string}` | `true_${number}@c.us_${string}`>

    Promise

unmuteChat

  • unmuteChat(chatId: ChatId): Promise<string | number | boolean>

updateWebhook

  • 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

    Returns Promise<false | Webhook>