WhatsAppAPI

WhatsAppAPI

The main API object

Constructor

new WhatsAppAPI(token, v)

Source:
Properties:
Name Type Description
token String The API token
v String The API version to use
Initiate the Whatsapp API app
Parameters:
Name Type Default Description
token String The API token, given at setup. It can be either a temporal token or a permanent one.
v String v14.0 The version of the API, defaults to v14.0
Throws:
If token is not specified
Type
Error

Methods

createQR(phoneID, message, format) → {Promise}

Source:
Generate a QR code for sharing the bot
Parameters:
Name Type Default Description
phoneID String The bot's phone ID
message String The quick message on the QR code
format String png The format of the QR code (png or svn)
Throws:
  • If phoneID is not specified
    Type
    Error
  • If message is not specified
    Type
    Error
  • If format is not either 'png' or 'svn'
    Type
    Error
Returns:
The fetch promise
Type
Promise

deleteQR(phoneID, id) → {Promise}

Source:
Delete a QR code of the bot
Parameters:
Name Type Description
phoneID String The bot's phone ID
id String The QR's id to delete
Throws:
  • If phoneID is not specified
    Type
    Error
  • If id is not specified
    Type
    Error
Returns:
The fetch promise
Type
Promise

logSentMessages(callback) → {WhatsAppAPI}

Source:
Set a callback function for sendMessage
Parameters:
Name Type Description
callback Logger The callback function to set
Throws:
If callback is truthy and is not a function
Type
Error
Returns:
The API object, for chaining
Type
WhatsAppAPI

markAsRead(phoneID, messageId) → {Promise}

Source:
Mark a message as read
Parameters:
Name Type Description
phoneID String The bot's phone ID
messageId String The message ID
Throws:
  • If phoneID is not specified
    Type
    Error
  • If messageId is not specified
    Type
    Error
Returns:
The fetch promise
Type
Promise

retrieveQR(phoneID, idopt) → {Promise}

Source:
Get one or many QR codes of the bot
Parameters:
Name Type Attributes Description
phoneID String The bot's phone ID
id String <optional>
The QR's id to find. If not specified, all QRs will be returned
Throws:
If phoneID is not specified
Type
Error
Returns:
The fetch promise
Type
Promise

sendMessage(phoneID, to, object, contextopt) → {Promise}

Source:
Send a Whatsapp message
Parameters:
Name Type Attributes Description
phoneID String The bot's phone ID
to String The user's phone number
object Text | Audio | Document | Image | Sticker | Video | Location | Contacts | Interactive | Template A Whatsapp component, built using the corresponding module for each type of message.
context String <optional>
The message ID of the message to reply to
Throws:
  • If phoneID is not specified
    Type
    Error
  • If to is not specified
    Type
    Error
  • If object is not specified
    Type
    Error
Returns:
The fetch promise
Type
Promise

updateQR(phoneID, id, message) → {Promise}

Source:
Update a QR code of the bot
Parameters:
Name Type Description
phoneID String The bot's phone ID
id String The QR's id to edit
message String The new quick message for the QR code
Throws:
  • If phoneID is not specified
    Type
    Error
  • If id is not specified
    Type
    Error
  • If message is not specified
    Type
    Error
Returns:
The fetch promise
Type
Promise