π·Venom BotπΈ
![](https://img.shields.io/discord/772885202351292426?color=blueviolet&label=discord&style=flat)
![release-it](https://img.shields.io/badge/%F0%9F%93%A6%F0%9F%9A%80-release--it-e10079.svg)
Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
Get started fast and easy! Official API!
Full Documentation
It's a high-performance alternative API to whatsapp, you can send, text messages, files, images, videos and more.
Remember, the API was developed on a platform called RESTful Web services, providing interoperability between computer systems on the Internet.
It uses a set of well-defined operations that apply to all information resources: HTTP itself defines a small set of operations, the most important being POST, GET, PUT and DELETE.
Use it in your favorite language like PHP, Python, C# and others. as long as your language is supported with the HTTP protocol, you will save time and money. you don't need to know how Venom works, we have the complete API documentation, in a professional way!
Get our official API Venom ! Contact us!
![whatsapp](https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/WhatsApp_logo.svg/2000px-WhatsApp_logo.svg.png)
Venom group support on Telegram
![Telegram](https://user-images.githubusercontent.com/66584466/117182238-7d1d8980-adac-11eb-9a70-e32f90c3d4e5.png)
Venom group support on Discord
![Discord](https://s2.glbimg.com/GUbCgnBxJERAmuaYcrjBzTXD5ws=/0x0:800x272/984x0/smart/filters:strip_icc()/i.s3.glbimg.com/v1/AUTH_63b422c2caee4269b8b34177e8876b93/internal_photos/bs/2021/d/N/zJs579QOGxKVRxfPILCA/discord-app.png)
Meet the Superchats
SuperChats is a premium library with unique features that control Whatsapp functions with socket.
With Superchats you can build service bots, multiservice chats or any system that uses Whatsapp
Superchats is a premium version of Venom, with exclusive features and support for companies and developers worldwide
https://github.com/orkestral/superchats
Buy a license Superchats
The value of the license is $50 monthly dollars, to acquire contact in whatsapp by clicking on the image below !!
![whatsapp](https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/WhatsApp_logo.svg/2000px-WhatsApp_logo.svg.png)
π·π· Functions Venomπ·π·
| |
---|
π» Automatic QR Refresh | β |
π Send text, image, video, audio and docs | β |
π₯ Get contacts, chats, groups, group members, Block List | β |
π Send contacts | β |
Send Buttons | β |
Send stickers | β |
Send stickers GIF | β |
Multiple Sessions | β |
β© Forward Messages | β |
π₯ Receive message | β |
π€ insert user section | β |
π Send location!! | β |
πΈπΈ and much more | β |
Documentation at https://orkestral.github.io/venom/index.html
Installation
> npm i --save venom-bot
or for Nightly releases:
> npm i --save https://github.com/orkestral/venom/releases/download/nightly/venom-bot-nightly.tgz
Installing the current repository "you can download the beta version from the current repository!"
> npm i github:orkestral/venom
Getting started
const venom = require('venom-bot');
venom
.create({
session: 'session-name'
})
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
});
function start(client) {
client.onMessage((message) => {
if (message.body === 'Hi' && message.isGroupMsg === false) {
client
.sendText(message.from, 'Welcome Venom π·')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
}
});
}
After executing create()
function, venom will create an instance of whatsapp web. If you are not logged in, it will print a QR code in the terminal. Scan it with your phone and you are ready to go!
Venom will remember the session so there is no need to authenticate everytime.
Multiples sessions can be created at the same time by pasing a session name to create()
function:
venom.create('sales').then((salesClient) => {...});
venom.create('support').then((supportClient) => {...});
Optional create parameters
Venom create()
method third parameter can have the following optional parameters:
If you are using the Linux
server do not forget to pass the args --user-agent
Original parameters in browserArgs
const venom = require('venom-bot');
venom
.create(
'sessionName',
(base64Qrimg, asciiQR, attempts, urlCode) => {
console.log('Number of attempts to read the qrcode: ', attempts);
console.log('Terminal qrcode: ', asciiQR);
console.log('base64 image string qrcode: ', base64Qrimg);
console.log('urlCode (data-ref): ', urlCode);
},
(statusSession, session) => {
console.log('Status Session: ', statusSession);
console.log('Session name: ', session);
},
{
browserPathExecutable: '',
folderNameToken: 'tokens',
mkdirFolderToken: '',
headless: 'new',
devtools: false,
debug: false,
logQR: true,
browserWS: '',
browserArgs: [''],
addBrowserArgs: [''],
puppeteerOptions: {},
disableSpins: true,
disableWelcome: true,
updatesLog: true,
autoClose: 60000,
createPathFileToken: false,
addProxy: [''],
userProxy: '',
userPass: ''
},
(browser, waPage) => {
console.log('Browser PID:', browser.process().pid);
waPage.screenshot({ path: 'screenshot.png' });
}
)
.then((client) => {
start(client);
})
.catch((erro) => {
console.log(erro);
});
Callback Status Session
Gets the return if the session is isLogged
or notLogged
or browserClose
or qrReadSuccess
or qrReadFail
or autocloseCalled
or desconnectedMobile
or deleteToken
or chatsAvailable
or deviceNotConnected
or serverWssNotConnected
or noOpenBrowser
or initBrowser
or openBrowser
or connectBrowserWs
or initWhatsapp
or erroPageWhatsapp
or successPageWhatsapp
or waitForLogin
or waitChat
or successChat
or Create session wss return "serverClose" case server for close
Status | Condition |
---|
isLogged | When the user is already logged in to the browser |
notLogged | When the user is not connected to the browser, it is necessary to scan the QR code through the cell phone in the option WhatsApp Web |
browserClose | If the browser is closed this parameter is returned |
qrReadSuccess | If the user is not logged in, the QR code is passed on the terminal a callback is returned. After the correct reading by cell phone this parameter is returned |
qrReadFail | If the browser stops when the QR code scan is in progress, this parameter is returned |
autocloseCalled | The browser was closed using the autoClose command |
desconnectedMobile | Client has desconnected in to mobile |
serverClose | Client has desconnected in to wss |
deleteToken | If you pass true within the function |
chatsAvailable | When Venom is connected to the chat list |
deviceNotConnected | Chat not available because the phone is disconnected (Trying to connect to the phone) |
serverWssNotConnected | The address wss was not found! |
noOpenBrowser | It was not found in the browser, or some command is missing in args |
initBrowser | Starting the browser |
openBrowser | The browser has been successfully opened! |
connectBrowserWs | Connection with BrowserWs successfully done! |
initWhatsapp | Starting whatsapp! |
erroPageWhatsapp | Error accessing whatsapp page |
successPageWhatsapp | Page Whatsapp successfully accessed |
waitForLogin | Waiting for login verification! |
waitChat | Waiting for the chat to load |
successChat | Chat successfully loaded! |
const venom = require('venom-bot');
venom
.create('sessionName', undefined, (statusSession, session) => {
console.log('Status Session: ', statusSession);
console.log('Session name: ', session);
})
.then((client) => {
start(client);
})
.catch((erro) => {
console.log(erro);
});
Exporting QR Code
By default QR code will appear on the terminal. If you need to pass the QR
somewhere else heres how:
const fs = require('fs');
const venom = require('venom-bot');
venom
.create(
'sessionName',
(base64Qr, asciiQR, attempts, urlCode) => {
console.log(asciiQR);
var matches = base64Qr.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/),
response = {};
if (matches.length !== 3) {
return new Error('Invalid input string');
}
response.type = matches[1];
response.data = new Buffer.from(matches[2], 'base64');
var imageBuffer = response;
require('fs').writeFile(
'out.png',
imageBuffer['data'],
'binary',
function (err) {
if (err != null) {
console.log(err);
}
}
);
},
undefined,
{ logQR: false }
)
.then((client) => {
start(client);
})
.catch((erro) => {
console.log(erro);
});
Downloading Files
Puppeteer takes care of the file downloading. The decryption is being done as
fast as possible (outruns native methods). Supports big files!
import fs = require('fs');
import mime = require('mime-types');
client.onMessage( async (message) => {
if (message.isMedia === true || message.isMMS === true) {
const buffer = await client.decryptFile(message);
const fileName = `some-file-name.${mime.extension(message.mimetype)}`;
fs.writeFile(fileName, buffer, (err) => {
...
});
}
});
Basic Functions (usage)
Not every available function is listed, for further look, every function
available can be found in here and
here
Chatting
Here, chatId
could be <phoneNumber>@c.us
or <phoneNumber>-<groupId>@g.us
const poll = {
name: 'new poll',
options: [
{
name: 'option 1'
},
{
name: 'option 2'
}
],
selectableOptionsCount: 1
};
await client.sendPollCreation('000000000000@c.us', poll)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
const list = [
{
title: "Pasta",
rows: [
{
title: "Ravioli Lasagna",
description: "Made with layers of frozen cheese",
}
]
},
{
title: "Dessert",
rows: [
{
title: "Baked Ricotta Cake",
description: "Sweets pecan baklava rolls",
},
{
title: "Lemon Meringue Pie",
description: "Pastry filled with lemonand meringue.",
}
]
}
];
await client.sendListMenu('000000000000@c.us', 'Title', 'subTitle', 'Description', 'menu', list)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
const buttons = [
{
"buttonText": {
"displayText": "Text of Button 1"
}
},
{
"buttonText": {
"displayText": "Text of Button 2"
}
}
]
await client.sendButtons('000000000000@c.us', 'Title', 'Description', buttons)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.sendVoice('000000000000@c.us', './audio.mp3').then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.sendVoiceBase64('000000000000@c.us', base64MP3)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendContactVcard('000000000000@c.us', '111111111111@c.us', 'Name of contact')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendContactVcardList('000000000000@c.us', [
'111111111111@c.us',
'222222222222@c.us',
])
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendText('000000000000@c.us', 'π Hello from venom!')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
let success = await client.sendTextViaTyping('000000000000@c.us', 'π Hello from venom!');
let success = await client.sendPhotoVideoViaTyping('000000000000@c.us', 'path/to/file.jpg', 'Pretty sunset');
await client
.sendLocation('000000000000@c.us', '-13.6561589', '-69.7309264', 'Brasil')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendLinkPreview(
'000000000000@c.us',
'https://www.youtube.com/watch?v=V1bFr2SWP1I',
'Kamakawiwo ole'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendImage(
'000000000000@c.us',
'path/to/img.jpg',
'image-name',
'Caption text'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.sendImageFromBase64('000000000000@c.us', base64Image, "name file")
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendFile(
'000000000000@c.us',
'path/to/file.pdf',
'file_name',
'See my file in pdf'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendFileFromBase64(
'000000000000@c.us',
base64PDF,
'file_name.pdf',
'See my file in pdf'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendImageAsStickerGif('000000000000@c.us', './image.gif')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendImageAsSticker('000000000000@c.us', './image.jpg')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.forwardMessages(
'000000000000@c.us',
['false_000000000000@c.us_B70847EE89E22D20FB86ECA0C1B11609','false_000000000000@c.us_B70847EE89E22D20FB86ECA0C1B11777']
).then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.sendMentioned(
'000000000000@c.us',
'Hello @5218113130740 and @5218243160777!',
['5218113130740', '5218243160777']
);
await client.reply(
'000000000000@c.us',
'This is a reply!',
'true_551937311025@c.us_7C22WHCB6DKYHJKQIEN9'
).then((result) => {
console.log('Result: ', result);
}).catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.
.sendMessageOptions(
'000000000000@c.us',
'This is a reply!',
{
quotedMessageId: reply,
}
)
.then((retorno) => {
resp = retorno;
})
.catch((e) => {
console.log(e);
});
await client.sendVideoAsGif(
'000000000000@c.us',
'path/to/video.mp4',
'video.gif',
'Gif image file'
);
checkReply = await client.returnReply(messagem);
await client.sendSeen('000000000000@c.us');
await client.startTyping('000000000000@c.us');
await client.setChatState('000000000000@c.us', 0 | 1 | 2);
Retrieving Data
const chats = await client.getAllChats();
const chatsAllNew = getAllChatsNewMsg();
const contacts = await client.getAllChatsContacts();
const contactNewMsg = await client.getChatContactNewMsg();
const chats = await client.getAllChatsGroups();
const groupNewMsg = await client.getChatGroupNewMsg();
const transmission = await client.getAllChatsTransmission();
const contacts = await client.getAllContacts();
const listMute = await client.getListMute('all');
const getBlockList = await client.getBlockList();
const Messages = await client.getAllMessagesInChat('000000000000@c.us');
const moreMessages = await client.loadEarlierMessages('000000000000@c.us');
const allMessages = await client.loadAndGetAllMessagesInChat(
'000000000000@c.us'
);
const status = await client.getStatus('000000000000@c.us');
const user = await client.getNumberProfile('000000000000@c.us');
const messages = await client.getUnreadMessages();
const url = await client.getProfilePicFromServer('000000000000@c.us');
const chat = await client.getChat('000000000000@c.us');
const chat = await client
.checkNumberStatus('000000000000@c.us')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
Group Functions
await client
.setGroupDescription('00000000-000000@g.us', 'group description')
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.leaveGroup('00000000-000000@g.us');
await client.getGroupMembers('00000000-000000@g.us');
await client.getGroupMembersIds('00000000-000000@g.us');
await client.getGroupInviteLink('00000000-000000@g.us');
await client.createGroup('Group name', [
'111111111111@c.us',
'222222222222@c.us'
]);
await client.removeParticipant('00000000-000000@g.us', '111111111111@c.us');
await client.addParticipant('00000000-000000@g.us', '111111111111@c.us');
await client.promoteParticipant('00000000-000000@g.us', '111111111111@c.us');
await client.demoteParticipant('00000000-000000@g.us', '111111111111@c.us');
await client.getGroupAdmins('00000000-000000@g.us');
await client.getGroupInfoFromInviteLink(InviteCode);
await client.joinGroup(InviteCode);
Profile Functions
await client.setProfileStatus('On vacations! βοΈ');
await client.setProfileName('Venom bot');
await client.setProfilePic('path/to/image.jpg');
await client.getHostDevice();
Device Functions
await client.logout();
await client.killServiceWorker();
await client.restartService();
await client.getConnectionState();
await client.getBatteryLevel();
await client.isConnected();
await client.getWAVersion();
Events
client.onAnyMessage(message => {
...
};
client.onMessage(message => {
...
})
client.onMessageEdit(message => {
...
})
client.onMessageDelete(message => {
...
})
client.onStateChange(state => {
...
});
client.onAck(ack => {
...
});
client.onLiveLocation("000000000000@c.us", (liveLocation) => {
...
});
client.onParticipantsChanged("000000000000@c.us", (event) => {
...
});
client.onAddedToGroup(chatEvent => {
...
});
Other
await client
.checkChat(chatId)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.pinChat(chatId, true, false)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendMute(
'000000000000@c.us',
30,
'minutes'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client
.sendMute(
'000000000000@c.us'
)
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.setTheme('dark');
await client.getTheme();
await client.deleteChat('000000000000@c.us');
await client.clearChatMessages('000000000000@c.us');
await client.archiveChat(chatId, true);
await client
.deleteMessage('000000000000@c.us', [
'false_000000000000@c.us_B70847EE89E22D20FB86ECA0C1B11609',
'false_000000000000@c.us_B70847EE89E22D20FB86ECA0C1B11777'
])
.then((result) => {
console.log('Result: ', result);
})
.catch((erro) => {
console.error('Error when sending: ', erro);
});
await client.markUnseenMessage('000000000000@c.us');
await client.blockContact('000000000000@c.us');
await client.unblockContact('000000000000@c.us');
Misc
There are some tricks for a better usage of venom.
Keep session alive:
client.onStateChange((state) => {
console.log('State changed: ', state);
if ('CONFLICT'.includes(state)) client.useHere();
if ('UNPAIRED'.includes(state)) console.log('logout');
});
let time = 0;
client.onStreamChange((state) => {
console.log('State Connection Stream: ' + state);
clearTimeout(time);
if (state === 'DISCONNECTED' || state === 'SYNCING') {
time = setTimeout(() => {
client.close();
}, 80000);
}
});
client.onIncomingCall(async (call) => {
console.log(call);
client.sendText(call.peerJid, "Sorry, I still can't answer calls");
});
Closing (saving) sessions
Close the session properly to ensure the session is saved for the next time you
log in (So it won't ask for QR scan again). So instead of CTRL+C,
process.on('SIGINT', function() {
client.close();
});
try {
...
} catch (error) {
client.close();
}
Auto closing unsynced sessions
The auto close is enabled by default and the timeout is set to 60 sec.
Receives the time in milliseconds to countdown until paired.
Use "autoClose: 0 | false" to disable auto closing.
Debugging
WhatsApp Web Versions
You can use cached versions of WhatsApp Web by passing the webVersion
arguments as part of your venom options:
venom.create({
session: 'sessionname',
headless: false,
logQR: true,
webVersion: '2.2402.5'
})
.then((client) => {
start(client);
});
This feature can use any version available in the list at https://github.com/wppconnect-team/wa-version/tree/main/html
Development
Building venom is really simple although it contains 3 main projects inside
- Wapi project
> npm run build:wapi
- Middleware
> npm run build:middleware
> npm run build:jsQR
- Venom
> npm run build:venom
To build the entire project just run
> npm run build
Maintainers
Maintainers are needed, I cannot keep with all the updates by myself. If you are
interested please open a Pull Request.
Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.