Class

WABOT

WABOT(opts)

Constructor

# new WABOT(opts)

WABOT class for interact whit whatsapp web

Parameters:
Name Type Description
opts object

Wabot options

puppeteerConfig object

Puppeteer launch options

puppeteerConfig.WAUrl string

Whatsapp Web Url

puppeteerConfig.sessionPath string

Path to save the session info for restore this in the future

puppeteerConfig.viewBrowser boolean

Show browser (headless)

puppeteerConfig.opendevtools boolean

Show devtools (console)

puppeteerConfig.userAgent string

User Agent for web browser

puppeteerConfig.width number

Width for web browser

puppeteerConfig.heigth number

Height for web browser

puppeteerConfig.dowloadChromeVersion boolean

Download chromium browser or use local google chome

puppeteerConfig.chromeVersion number

Version of chromium to download

puppeteerConfig.localChromePath string

Google chrome executable path

puppeteerConfig.getInitScreenshot string

Allows you to take a screenshot when you start WhatsApp in order to detect problems when running in headless mode

puppeteerConfig.localChromePath string

File name to save the screenshot

puppeteerConfig.args string

Args to open the web browser

intentConfig object

Execution and internal options

intentConfig.showContent boolean

Display chats in browser

intentConfig.debug string

Debug mode for view console logs

intentConfig.removeBgApis Array.<string>

Api keys for https://www.remove.bg

intentConfig.plugins object

Options for plugins config

intentConfig.plugins.folder string

Folder containing the plugins

intentConfig.plugins.plugins Array.<string>

Array containing the plugin names to use

intentConfig.plugins.setup object

Configuration of each plugin

intentConfig.executions object

Options for control chats

intentConfig.executions.reponseUsers boolean

Control response to users

intentConfig.executions.simulateTyping boolean

Simulate typing in chat

intentConfig.executions.timeSimulate number

Time in ms for simulate typing

intentConfig.executions.contorlExecutions boolean

Control chats to enqueue messages

intentConfig.executions.maxExecutions number

Max messages to process in the same time

intentConfig.executions.timeInterval number

Time in seconds to queue messages

intentConfig.executions.timePending number

Time in minutes to search for pending messages

intentConfig.executions.sendSeen boolean

Send seen ticket

intentConfig.executions.sendSeenFull boolean

Send seen ticket to all pending messages on login

intentConfig.executions.intervalSendSeen number

Time in minutes for search pending messages to send seen

intentConfig.bann object

Bann options

intentConfig.bann.active boolean

Control bann users

intentConfig.bann.timeInterval number

Time in seconds to validate spam messages

intentConfig.bann.maxBann number

Maximum number of messages allowed in the indicated amount of time

intentConfig.bann.timeBann number

Time in minutes for temporary ban

intentConfig.bann.timeInactive number

Time in minutes to release banned users who are inactive for the specified time

intentConfig.bann.whiteList Array.<string>

List of users who will not be banned

intentConfig.messages object

Message settings

intentConfig.messages.userBanned string

Message to display when a user is banned

intentConfig.messages.groupBanned string

Message to display when a group is banned

intentConfig.messages.privileges string

Message to display when you do not have privileges to use the bot

intentConfig.blocked Array.<string>

List of users who cannot use the bot

intentConfig.whiteList Array.<string>

List of users who can use the bot

intentConfig.commands Array.<object>

List of commands to evaluate in user messages

intentConfig.commands.name string

Name of the command

intentConfig.commands.contains Array.<string>

Contains word on message

intentConfig.commands.exact Array.<string>

Message is the same as what is contained here

intentConfig.commands.params Array.<object>

Parameters to require

intentConfig.commands.params.name string

Name of the param

intentConfig.commands.params.isNumber boolean

Is a number param

intentConfig.commands.params.request Array.<string>

Questions to request the parameter

intentConfig.commands.params.values Array.<string>

Allowed values. If any is allowed, "any" must be indicated

intentConfig.commands.params.badResponse Array.<string>

Messages to send in case of illegal values

session object

Object containing session information. Can be used to restore the session.

session.WABrowserId string
session.WASecretBundle string
session.WAToken1 string
session.WAToken2 string

View Source src/WABOT.js, line 30

Extends

  • EventEmitter

Methods

# async archiveChat() → {boolean}

Enables and returns the archive state of the Chat

View Source src/WABOT.js, line 1091

boolean

# async archiveChat() → {boolean}

Enables and returns the archive state of the Chat

View Source src/WABOT.js, line 1158

boolean

# async createGroup(name, contactsId) → {Object|string|Object.<string, string>}

Create a new group

Parameters:
Name Type Description
name string

group title

contactsId Array.<(Contact|string)>

an array of Contacts or contact IDs to add to the group

View Source src/WABOT.js, line 1014

createRes

Object

createRes.gid - ID for the group that was just created

string

createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.

Object.<string, string>

# async downloadFile(idMessage) → {Promise.<string>}

Download file from message received from others users

Parameters:
Name Type Description
idMessage string

Message id containing the file to download

View Source src/WABOT.js, line 642

file in base64 or error message

Promise.<string>

# async getAllChats() → {Promise.<Array.<Object>>}

Get all chats

View Source src/WABOT.js, line 948

Promise.<Array.<Object>>

# async getAllChatsWithNewMsg() → {Promise.<Array.<Object>>}

Get all chats with pending messages

View Source src/WABOT.js, line 956

Promise.<Array.<Object>>

# async getAllContacts(contactId) → {Promise.<Array.<Contact>>}

Gets the list of all users

Parameters:
Name Type Description
contactId string

View Source src/WABOT.js, line 1023

Promise.<Array.<Contact>>

# async getAllGroupMetadata() → {Array|*}

Fetches all group metadata objects from store

View Source src/WABOT.js, line 992

List of group metadata

Array | *

# async getAllUnreadMessages() → {Promise.<Array.<Object>>}

Get all unread messages

View Source src/WABOT.js, line 983

Promise.<Array.<Object>>

# async getBatteryLevel() → {number}

Get current battery percentage and charging status for the attached device

View Source src/WABOT.js, line 940

battery - The current battery percentage

number

# async getChatById(chatId) → {Promise.<Chat>}

Get chat instance by ID

Parameters:
Name Type Description
chatId string

View Source src/WABOT.js, line 965

Promise.<Chat>

# async getContactById(contactId) → {Promise.<Contact>}

Get contact instance by ID

Parameters:
Name Type Description
contactId string

View Source src/WABOT.js, line 1041

Promise.<Contact>

Get the invite code's group

Parameters:
Name Type Description
chatId string

View Source src/WABOT.js, line 1059

Invite Code

Promise.<string>

# async getGroupMetadata(groupId) → {T|*}

Fetches group metadata object from store by ID

Parameters:
Name Type Description
groupId string

ID of group

View Source src/WABOT.js, line 1002

Group metadata object

T | *

# async getInviteInfo(inviteCode) → {Promise.<object>}

Returns an object with information about the invite code's group

Parameters:
Name Type Description
inviteCode string

View Source src/WABOT.js, line 1050

Invite information

Promise.<object>

# async getMe() → {Promise.<object>}

Returns an object with all of your host device details

View Source src/WABOT.js, line 924

Promise.<object>

# async getMessageById(messageId) → {Promise.<Array.<Object>>}

Get message by Id

Parameters:
Name Type Description
messageId string

Message Id

View Source src/WABOT.js, line 975

Promise.<Array.<Object>>

# async getMyContacts(contactId) → {Promise.<Array.<Contact>>}

Get the user's registered contact list

Parameters:
Name Type Description
contactId string

View Source src/WABOT.js, line 1032

Promise.<Array.<Contact>>

# async getState()

Gets the current connection state for the client

View Source src/WABOT.js, line 1174

WAState

# async getStatus() → {string}

Gets the current status message

View Source src/WABOT.js, line 1083

status message

string

# async getWAVersion() → {Promise.<string>}

Returns the version of WhatsApp Web currently being run

View Source src/WABOT.js, line 932

Promise.<string>

# isReady()

To know if the process is ready

View Source src/WABOT.js, line 1198

Accepts an invitation to join a group

Parameters:
Name Type Description
inviteCode string

Invitation code

View Source src/WABOT.js, line 1067

# logout()

Logs out the client, closing the current session

View Source src/WABOT.js, line 1188

# async muteChat(chatId, unmuteDate)

Mutes the Chat until a specified date

Parameters:
Name Type Description
chatId string

ID of the chat that will be muted

unmuteDate Date

Date when the chat will be unmuted

View Source src/WABOT.js, line 1126

# async pinChat() → {Promise.<boolean>}

Pins the Chat

View Source src/WABOT.js, line 1142

New pin state. Could be false if the max number of pinned chats was reached.

Promise.<boolean>

# async resetState()

Force reset of connection state for the client

View Source src/WABOT.js, line 1181

# sendFile(args)

Send a file

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

file string

Url, base64 or path to the file

View Source src/WABOT.js, line 705

# sendGif(args)

Send a gif file

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

file string

Url, base64 or path to the file

View Source src/WABOT.js, line 757

# sendImage(args)

Send a image file

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

file string

Url, base64 or path to the file

View Source src/WABOT.js, line 679

Send a link

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

link string

Url to send

View Source src/WABOT.js, line 810

# sendLocation(args)

Send a location

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

lat string

Latitude of the location

lng string

Location of the location

title string

Title to display

View Source src/WABOT.js, line 853

# sendMessage(args)

Send text as image

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

message string

Message to send

View Source src/WABOT.js, line 627

# sendMusic(args)

Send a music file

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

file string

Url, base64 or path to the file

View Source src/WABOT.js, line 783

# sendSticker(args)

Send a sticker

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

file string

Url, base64 or Path of the image (with or without background)

View Source src/WABOT.js, line 826

# sendText2Image(args)

Send text as image

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

message string

Message to convert into image

View Source src/WABOT.js, line 662

# sendVcard(args)

Send a contact as vcard

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

contactName string

Contact Name to display

vcard object

Contact info

vcard.firstName string

First Name

vcard.middleName string

Middle Name

vcard.lastName string

Last Name

vcard.organization string

Organization

vcard.birthday string

Dirthday date

vcard.title string

Title to display

vcard.url string

Url

vcard.note string

Note

vcard.nickname string

Nickname

vcard.namePrefix string

Name Prefix

vcard.nameSuffix string

Name Suffix

vcard.gender string

Gender

vcard.role string

Role

vcard.homePhone string

Home Phone

vcard.workPhone string

Work Phone

vcard.cellPhone string

Cell Phone

vcard.pagerPhone string

Pager Phone

vcard.homeFax string

Home Fax

vcard.workFax string

Work Fax

vcard.email string

Email

vcard.workEmail string

Work Email

vcard.socialUrlsFacebook string

Social Urls Facebook

vcard.socialUrlsLinkedin string

Social Urls Linkedin

vcard.socialUrlsTwitter string

Social Urls Twitter

vcard.socialUrlsFlickr string

Social Urls Flickr

vcard.socialUrlsCustom string

Social Urls Custom

vcard.homeAddressLabel string

Home Address Label

vcard.homeAddressStreet string

Home Address Street

vcard.homeAddressCity string

Home Address City

vcard.homeAddressStateProvince string

Home Address State Province

vcard.homeAddressPostalCode string

Home Address Postal Code

vcard.homeAddressCountryRegion string

Home Address Country Region

vcard.workAddressLabel string

Work Address Label

vcard.workAddressStreet string

Work Address Street

vcard.workAddressCity string

Work Address City

vcard.workAddressStateProvince string

Work Address State Province

vcard.workAddressPostalCode string

Work Address Postal Code

vcard.workAddressCountryRegion string

Work Address Country Region

vcard.photo string

Photo (url or path)

View Source src/WABOT.js, line 909

# sendVideo(args)

Send a video file

Parameters:
Name Type Description
args object

The message info

idChat string

Id Chat

idMessage string

Id of message to reply

caption string

Caption to display in the message

file string

Url, base64 or path to the file

View Source src/WABOT.js, line 731

# async setDisplayName(displayName)

Sets the current user's display name. This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.

Parameters:
Name Type Description
displayName string

New display name

View Source src/WABOT.js, line 1108

# async setPresence(presence)

Marks the client as online or offline

Parameters:
Name Type Description
presence boolean

true for online false for offline

View Source src/WABOT.js, line 1099

# async setStatusMessage(status)

Sets the current user's status message

Parameters:
Name Type Description
status string

New status message

View Source src/WABOT.js, line 1075

# start()

Start session on whatsapp web

View Source src/WABOT.js, line 1204

# async unarchiveChat() → {boolean}

Changes and returns the archive state of the Chat

View Source src/WABOT.js, line 1166

boolean

# async unmuteChat(chatId)

Unmutes the Chat

Parameters:
Name Type Description
chatId string

ID of the chat that will be unmuted

View Source src/WABOT.js, line 1134

# async unpinChat() → {Promise.<boolean>}

Unpins the Chat

View Source src/WABOT.js, line 1150

New pin state

Promise.<boolean>

# async validNumberExists(id) → {Promise.<Boolean>}

Check if a given ID is registered in whatsapp

Parameters:
Name Type Description
id string

the whatsapp user's ID

View Source src/WABOT.js, line 1117

Promise.<Boolean>

Events

# command

Emitted when a command is detected

Parameters:
Name Type Description
arg object

Message Info

View Source src/WABOT.js, line 277

# message

Emitted when an uncontrolled message is received

Parameters:
Name Type Description
arg object

Message Info

View Source src/WABOT.js, line 261

# onAddedToGroup

Emitted when add a participant of the group

Parameters:
Name Type Description
arg object

View Source src/WABOT.js, line 201

# onBattery

Emitted when the battery percentage for the attached device changes

Parameters:
Name Type Description
arg number

The current battery percentage

View Source src/WABOT.js, line 183

# onMessageFromBloqued

Emitted when a message is received from a bloqued user

Parameters:
Name Type Description
arg object

Message info

View Source src/WABOT.js, line 156

# onMessageFromNoPrivileges

Emitted when a message is received from a non-privileged user

Parameters:
Name Type Description
arg object

Message info

View Source src/WABOT.js, line 165

# onMessageMediaUploadedEvent

Emitted when media has been uploaded for a message sent by the client.

Parameters:
Name Type Description
message object

The message with media that was uploaded

View Source src/WABOT.js, line 231

# onParticipantsChanged

Emitted when a participant of the group change

Parameters:
Name Type Description
arg object
by string
action string

Promote or Demote

who string

Id of the user

View Source src/WABOT.js, line 219

# onPlugged

Emitted when add a participant of the group

Parameters:
Name Type Description
arg boolean

True or False

View Source src/WABOT.js, line 192

# onRemovedFromGroup

Emitted when remove a participant of the group

Parameters:
Name Type Description
arg object

View Source src/WABOT.js, line 210

# onStateChanged

Emitted when the connection state changes

Parameters:
Name Type Description
arg object

State info

View Source src/WABOT.js, line 147

# ready

Emitted when WABOT is ready to work

Parameters:
Name Type Description
session object

Object containing session information. Can be used to restore the session.

WABrowserId string
WASecretBundle string
WAToken1 string
WAToken2 string

View Source src/WABOT.js, line 241

# vcard

Emitted when a vcard pis received

Parameters:
Name Type Description
arg object

Message Info

View Source src/WABOT.js, line 269

# waitNewAcknowledgements

Emitted when a the acknowledgement state of a message changes.

Parameters:
Name Type Description
arg object

View Source src/WABOT.js, line 174