# 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 |
- WABOT#event:ready
- WABOT#event:onStateChanged
- WABOT#event:onMessageFromBloqued
- WABOT#event:onMessageFromNoPrivileges
- WABOT#event:waitNewAcknowledgements
- WABOT#event:onBattery
- WABOT#event:onPlugged
- WABOT#event:onRemovedFromGroup
- WABOT#event:onParticipantsChanged
- WABOT#event:onMessageMediaUploadedEvent
- WABOT#event:vcard
- WABOT#event:message
- WABOT#event:command
Extends
- EventEmitter
Methods
# 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 |
createRes
createRes.gid - ID for the group that was just created
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.
# 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 |
file in base64 or error message
# async getAllChatsWithNewMsg() → {Promise.<Array.<Object>>}
Get all chats with pending messages
# async getAllContacts(contactId) → {Promise.<Array.<Contact>>}
Gets the list of all users
Parameters:
Name | Type | Description |
---|---|---|
contactId |
string |
# async getAllGroupMetadata() → {Array|*}
Fetches all group metadata objects from store
List of group metadata
# async getAllUnreadMessages() → {Promise.<Array.<Object>>}
Get all unread messages
# async getBatteryLevel() → {number}
Get current battery percentage and charging status for the attached device
battery - The current battery percentage
# async getChatById(chatId) → {Promise.<Chat>}
Get chat instance by ID
Parameters:
Name | Type | Description |
---|---|---|
chatId |
string |
# async getContactById(contactId) → {Promise.<Contact>}
Get contact instance by ID
Parameters:
Name | Type | Description |
---|---|---|
contactId |
string |
# async getGroupInviteLink(chatId) → {Promise.<string>}
Get the invite code's group
Parameters:
Name | Type | Description |
---|---|---|
chatId |
string |
Invite Code
# async getGroupMetadata(groupId) → {T|*}
Fetches group metadata object from store by ID
Parameters:
Name | Type | Description |
---|---|---|
groupId |
string | ID of group |
Group metadata object
# async getInviteInfo(inviteCode) → {Promise.<object>}
Returns an object with information about the invite code's group
Parameters:
Name | Type | Description |
---|---|---|
inviteCode |
string |
Invite information
# async getMe() → {Promise.<object>}
Returns an object with all of your host device details
# async getMessageById(messageId) → {Promise.<Array.<Object>>}
Get message by Id
Parameters:
Name | Type | Description |
---|---|---|
messageId |
string | Message Id |
# async getMyContacts(contactId) → {Promise.<Array.<Contact>>}
Get the user's registered contact list
Parameters:
Name | Type | Description |
---|---|---|
contactId |
string |
# async getWAVersion() → {Promise.<string>}
Returns the version of WhatsApp Web currently being run
# async joinGroupViaLink(inviteCode)
Accepts an invitation to join a group
Parameters:
Name | Type | Description |
---|---|---|
inviteCode |
string | Invitation code |
# 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 |
# async pinChat() → {Promise.<boolean>}
Pins the Chat
New pin state. Could be false if the max number of pinned chats was reached.
# async resetState()
Force reset of connection state for the client
# 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 |
# 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 |
# 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 |
# sendLink(args)
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 |
# 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 |
# 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 |
# 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 |
# 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) |
# 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 |
# 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 | |
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) |
# 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 |
# 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 |
# async setPresence(presence)
Marks the client as online or offline
Parameters:
Name | Type | Description |
---|---|---|
presence |
boolean | true for online false for offline |
# async setStatusMessage(status)
Sets the current user's status message
Parameters:
Name | Type | Description |
---|---|---|
status |
string | New status message |
# async unmuteChat(chatId)
Unmutes the Chat
Parameters:
Name | Type | Description |
---|---|---|
chatId |
string | ID of the chat that will be unmuted |
# 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 |
Events
# command
Emitted when a command is detected
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | Message Info |
# message
Emitted when an uncontrolled message is received
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | Message Info |
# onAddedToGroup
Emitted when add a participant of the group
Parameters:
Name | Type | Description |
---|---|---|
arg |
object |
# onBattery
Emitted when the battery percentage for the attached device changes
Parameters:
Name | Type | Description |
---|---|---|
arg |
number | The current battery percentage |
# onMessageFromBloqued
Emitted when a message is received from a bloqued user
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | Message info |
# onMessageFromNoPrivileges
Emitted when a message is received from a non-privileged user
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | Message info |
# 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 |
# 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 |
# onPlugged
Emitted when add a participant of the group
Parameters:
Name | Type | Description |
---|---|---|
arg |
boolean | True or False |
# onRemovedFromGroup
Emitted when remove a participant of the group
Parameters:
Name | Type | Description |
---|---|---|
arg |
object |
# onStateChanged
Emitted when the connection state changes
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | State info |
# 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 |
# waitNewAcknowledgements
Emitted when a the acknowledgement state of a message changes.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object |