Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orkestral/super
SuperChats is a premium library with unique features that control Whatsapp functions. With Superchats you can build service bots, multiservice chats or any system that uses whatsapp
https://github.com/orkestral/super
chat chat-application chatbot multidevice venom venom-bot whatsapp whatsapp-api whatsapp-beta whatsapp-web
Last synced: 1 day ago
JSON representation
SuperChats is a premium library with unique features that control Whatsapp functions. With Superchats you can build service bots, multiservice chats or any system that uses whatsapp
- Host: GitHub
- URL: https://github.com/orkestral/super
- Owner: orkestral
- License: unlicense
- Created: 2021-09-28T04:07:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-06T00:39:17.000Z (4 months ago)
- Last Synced: 2025-01-01T07:03:15.767Z (9 days ago)
- Topics: chat, chat-application, chatbot, multidevice, venom, venom-bot, whatsapp, whatsapp-api, whatsapp-beta, whatsapp-web
- Homepage: https://orkestral.io/superchats
- Size: 760 KB
- Stars: 233
- Watchers: 12
- Forks: 35
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#
Access SuperChats git and leave your star
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 WhatsappSuperchats is a premium version of Venom, with exclusive features and support for companies and developers worldwide
## Buy a license
The value of the license is $50 monthly dollars, to acquire contact in whatsapp by clicking on the image below !!
## Quickstart
Run the following command to ensure you have SuperChats installed:
```bash
$ npm install superchats
```or using yarn:
```bash
$ yarn add superchats
```## Documentations
- Getting Started
- Multiples Sessions
- Optional Parameters
- Download and Save Files
- Disconnect Functions
- Message Sending Functions
- Send Text
- Send Image
- Send Sticker
- Send Video
- Send Audio
- Send Voice
- Send Document
- Send Location
- Send Contact
- Send Link
- Send Buttons
- Send List
- Get All Contacts
- Delete Message
- Forwarding Message
- Mute Chat
- Get Chats
- Read Chat Messages
- Get Block List
- Archive Chat
- Delete Chat
- Pin Chat
- Block Contact
- Get Profile Status
- Get Picture
- Set Picture
- Get Number Profile
- Groups Functions
- Create Group
- Add Participants Group
- Add Admins Group
- Change Name of Group
- Change Description of Group
- Join Group
- Leave Group
- Get Group Link
- Revoke Group Link
- Info Group
- Set Group Settings
- Get Groups List
- Get Host Device
- Chat Messages Functions
- Update Presence
- Send Messages for Status
- Observation Events## Getting Started
```javascript
const superchats = require("superchats");async function start(){
let client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
nodata: true,
logQr: false,
qr: true,
code: false,
statusFind: async (status) => {
console.log(status)
},
qrcode: async (session, base64Img, asciiQR, urlCode) => {
console.log(asciiQR)
},
onMessage: async (message) => {
if ((message.type == "text" || message.subtype == 'text') && message.content == "hi") {
await client.sendText(message.from, "Let's GO Superchats");
}
} // Receive an event all the time you receive a message from some contact
})return client;
}
(async function(){
let client = await start();
let response = await client.sendText('0000000000000', 'Thanks for using Superchats!!!')
console.log(response)
})()
```## Multiples Sessions
After executing create() function, **Superchats** will create an instance of whatsapp. 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!
**Superchats** 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:```javascript
// Init sales whatsapp bot
superchats.create({session:'sales', license: "asjdh-efddff734-sdsdf834-233272"}).then((salesClient) => {...});// Init support whatsapp bot
ssuperchats.create({session:'support', license: "asjdh-efddff734-sdsdf834-233272"}).then((supportClient) => {...});
```## Optional Parameters
Optional parameters are started along with the connection as events of **QRCODE and CONNECTION STATUS**, plus extra options
```javascript
const superchats = require("superchats");superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272", // Valid license to use Superchats
welcomeScreen: true, // Show or hide welcome in terminal
retries: 3, // Number of connection attempts,
nodata true, // It doesn't get the entire history of the device (default = true)
logQr: true, // (Default is true) Logs QR automatically in terminal
qr: true, // If marked true uses the QR code instead of the pairing code
code: false, // if marked true, uses the pairing code instead of the QR
phoneNumber: "556185290357", // Number for pairing with WhatsApp alternative to QR
qrcode: (sessionId, base64QR, asciiQR, urlCode) => {
console.log("sessionId: " + sessionId)
console.log("base64 image of qrcode: " + base64QR);
console.log("Terminal image of qrcode in caracter ascii: " + asciiQR);
console.log("Terminal string hash of qrcode: " + urlCode);
},
pairing: (sessionId, code){
console.log("Session name: " + sessionId)
console.log("Pairing code: " + code)
},
statusFind: (statusSession) => {
console.log("Status Session: ", statusSession);
},
onMessage: (event) => { // Receive an event all the time you receive a message from some contact
console.log(event)
},
onMessageFull: (event) => { // Receive an event all the time you receive a message complete no filters direct of socket do whatsapp
console.log(event)
},
onAck: (event) => { // Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read
console.log(event)
},
onPresence: (event) => { // Receive an event every time a contact is: typing, recording, online or offline with you
console.log(event)
},
onGroups: (event) => { // Receive events all time the name of a group, configurations are changed
console.log(event)
},
onParticipants: (event) => { // Receive events about group participants
console.log(event)
},
onDelete: (event) => { // Receive events every time a message is deleted
console.log(event)
}
})
```
## Callback StatusFindGet connection feedback by following codes:
| Status | Condition |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `isLogged` | When the client already has a valid token and will not need to read the qrcode again |
| `notLogged` | When the client does not have a valid token and needs to read the qr code again | |
| `isDisconnected` | The client has disconnected or has been disconnected |
| `isLogout` | The client has disconnected and removed the token from the device |
| `isConnected` | The client has successfully connected list |
| `serverDisconnected` | Disconnected for whatsapp socket server |
| `isReconnected` | notifies that it is connected so that you can check if it has been successfully connected |## Download and Save Files
Download and save any message file with the functions below
```javascript
let client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
onMessage: async (message) => {
if (message.isMedia === true) {
//retrieve the file buffer for a given message
// Attention, use a delay of at least 2 secondsconst buffer = await client.decryptByIdFile(message.from, message.id);
// Save the message file in the project's root or in a directory: './diretory/filename' don't forget to create the directory
// Attention, use a delay of at least 2 seconds
const saveFile = await client.decryptByIdFileSave(message.from, message.id, filename);
}
} // Receive an event all the time you receive a message from some contact
})```
##### Return of decryptFile
```javascript
{
session: 'Marketing',
status: 200,
type: "decrypt-by-id-file",
buffer: {
type: "Buffer",
data: [137,80,78,71,13,10,26,10,0,0,0,13,73,72,68]
}
}
```
##### Return of decryptFileSave
```javascript
{
session: 'Marketing',
status: 404,
type: "decrypt-by-id-file-save",
response: "./files/teste4.mp4"
}
```
## Disconnect Functions> Disconnect Functions
```javascript
client.close()
```
```javascript
client.logout()
```## Message Sending Functions
We created the easiest way to send messages with **Superchats**
> Sending messages can be sent to the contact's number, example: **5561981590153** or to a group ID, example: **15815954040-1631239154**
### Send Message Text
```javascript
let response = await client.sendText("5561981590153", "Thanks for using Superchats!!!");```
> To reply to a message, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendText("5561981590153", "Reply Message!!!", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'text',
id: '3EB01A690E67',
to: '556181590153',
content: 'Thanks for using Superchats!!!',
isgroup: false,
timestamp: 1633101992
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'text',
message: 'message of erro'
}
```
### Send Message Image> For image submission, you can use URL or the local file path
```javascript
let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Text optional");```
> To reply to a message with image, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Reply with image", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'image',
id: '3EB0FF4E2532',
to: '556181590153',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/AmkmMjj4ZqieB6bDxS-Trox10ldAe5aIUZ5uQLutyKL8.enc',
caption: 'Text optional',
mimetype: 'image/jpeg',
fileSha256: ,
fileLength: Long { low: 15183, high: 0, unsigned: true },
height: 0,
width: 0,
mediaKey: ,
fileEncSha256: ,
directPath: '',
thumbnail:
},
participant: '',
timestamp: 1633106913
}```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'image',
message: 'message of erro'
}
```### Send Message Sticker
> For image sticker submission, you can use URL or the local file path
```javascript
let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png");```
> To reply to a message with image sticker, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'sticker',
id: '3EB07B2F281B',
to: '556181590153',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/Ak39fUdprDRnKalZbWWyepoMbvNBlEOgIqZzY7GLEBil.enc',
mimetype: 'image/webp',
fileSha256: ,
fileLength: Long { low: 23001, high: 0, unsigned: true },
mediaKey: ,
fileEncSha256: ,
directPath: ''
},
participant: '',
timestamp: 1633129024
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'sticker',
message: 'message of erro'
}
```### Send Message Video
> For video submission, you can use URL or the local file path```javascript
let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Text optional");```
> To reply to a message with video, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Reply with video", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'video',
id: '3EB0612BED9B',
to: '556181590153',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/AnrExTInFHkr446WcJoVnbHhhb1Tdmg8ort6g1SweEvS.enc',
caption: 'Text optional',
mimetype: 'video/mp4',
fileSha256: ,
fileLength: Long { low: 2252313, high: 0, unsigned: true },
mediaKey: ,
fileEncSha256: ,
directPath: '',
thumbnail:
},
participant: '',
timestamp: 1633108332
}```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'video',
message: 'message of erro'
}
```### Send Message Audio
> For audio submission, you can use URL or the local file path```javascript
let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3");```
> To reply to a message with audio, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'audio',
id: '3EB072B039F6',
to: '556181590153',
content: '',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc',
mimetype: 'audio/ogg; codecs=opus',
fileSha256: ,
fileLength: Long { low: 764176, high: 0, unsigned: true },
seconds: 27,
mediaKey: ,
fileEncSha256: ,
directPath: ''
},
participant: '',
timestamp: 1633111077
}```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'audio',
message: 'message of erro'
}
```
### Send Message Audio Voice
> For audio voice submission, you can use URL or the local file path```javascript
let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3");```
> To reply to a message with audio voice, use the id of the message you want to reply to in the last parameter, which is optional.
```javascript
let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67');
```##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'voice',
id: '3EB072B039F6',
to: '556181590153',
content: '',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc',
mimetype: 'audio/ogg; codecs=opus',
fileSha256: ,
fileLength: Long { low: 764176, high: 0, unsigned: true },
seconds: 27,
mediaKey: ,
fileEncSha256: ,
directPath: ''
},
participant: '',
timestamp: 1633111077
}```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'voice',
message: 'message of erro'
}
```### Send Message Document
> For document submission, you can use URL or the local file path```javascript
let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional");```
> To reply to a message with document, use the id of the message you want to reply to in the last parameter, which is optional.```javascript
let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional", '3EB01A690E67');
```
##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'document',
id: '3EB07C8C333C',
to: '556181590153',
isgroup: false,
file: {
url: 'https://mmg.whatsapp.net/d/f/ArJfVUhnzdW7qcBk8-T-mzRWsfMN6k_WOS81td_xJs6E.enc',
mimetype: 'application/pdf',
filename: 'Filename Optional',
fileSha256: ,
fileLength: Long { low: 20597, high: 0, unsigned: true },
mediaKey: ,
fileEncSha256: ,
directPath: '',
thumbnail:
},
participant: '',
timestamp: 1633121433
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'document',
message: 'message of erro'
}
```
### Send Message Location```javascript
let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional');```
> To reply to a message with location, use the id of the message you want to reply to in the last parameter, which is optional.```javascript
let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional', '3EB01A690E67');
```
##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'location',
id: '3EB01A3D9A34',
to: '556181590153',
name: 'title optional',
address: 'address optional',
url: '',
thumbnail: ,
latitude: -15.8413105,
longitude: -48.0270346,
isgroup: false,
participant: '',
timestamp: 1633122748
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'location',
message: 'message of erro'
}
```
### Send Message Contact```javascript
let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040');```
> To reply to a message with contact, use the id of the message you want to reply to in the last parameter, which is optional.```javascript
let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040', '3EB01A690E67');
```
##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'contact',
id: '3EB00AFB1F60',
to: '556181590153',
display: 'Name of Contact',
vcard: 'BEGIN:VCARD\n' +
'VERSION:3.0\n' +
'FN:Name of Contact\n' +
'TEL;type=CELL;type=VOICE;waid=15815954040:+15815954040\n' +
'END:VCARD',
isgroup: false,
timestamp: 1633128149
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'contact',
message: 'message of erro'
}
```
### Send Message Link```javascript
let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional');```
> To reply to a message with link, use the id of the message you want to reply to in the last parameter, which is optional.```javascript
let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional', '3EB01A690E67');
```
##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'link',
id: '3EB0746BE9A9',
to: '556181590153',
content: 'https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share\n' +
'Description optional',
isgroup: false,
timestamp: 1633130029
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'link',
message: 'message of erro'
}
```### Send Message List
> Attention! This function does not work if connected to a WhatsApp Business account```javascript
const sections = [
{
title: "Bovina",
rows: [
{ title: "Fraudinha", rowId: "carnes1" },
{ title: "Alcatra", rowId: "carnes2", description: "Carne boa" },
],
},
{
title: "Suina",
rows: [
{ title: "Costelinha", rowId: "carnes3" },
{
title: "Picanha Suina",
rowId: "carnes4",
description: "Carne boa",
},
],
},
];
//number of contact, name of button, sections array, title, description: optional, footer: optional
let response = await const response = await client.sendList(
"5561981590153",
"Escolha a Carne",
sections,
"Escolha 1 tipo de carne",
"", //Description opcional
"Qual o tipo de carne vai na sua refeição?"
);```
> To reply to a message with buttons, use the id of the message you want to reply to in the last parameter, which is optional.```javascript
//number of contact, name of button, sections array, title, description: optional, footer: optional, id message for reply
let response = await const response = await client.sendList(
"5561981590153",
"Escolha a Carne",
sections,
"Escolha 1 tipo de carne",
"", //Description opcional
"Qual o tipo de carne vai na sua refeição?",
"3EB01A690E67"
);
```
##### Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'list',
id: '3EB0F92B3F1D',
to: '556181590153',
description: 'Description optional',
btnName: 'Name of Button',
sections: [ Section { rows: [Array], title: 'Name of section' } ],
isgroup: false,
timestamp: 1633143340
}
```
##### Return with erro```javascript
{
session: 'Marketing',
status: 404,
type: 'list',
message: 'message of erro'
}
```## Delete Message
> Delete messages in chats only for you or for all
Delete message only for you
```javascript
//number of chat, id of message
let response = await client.deleteMessageMe("5561981590153", "3EB071B7776A")```
Delete Message to everyone on chat```javascript
//number of chat, id of message
let response = await client.deleteMessageAll("5561981590153", "3EB071B7776A")```
Return with success
```javascript
{
session: 'Marketing',
status: 200
type: 'delete-chat-me'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'delete-chat-me',
message: 'message of erro'
}
```
## Forwarding Message> Message forwarding for any contact
```javascript
//number of chat, id of message, number chat for send
let response = await client.forwardMessage("5561981590153", "3EB042FA6555", "15815954040")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'forwarding',
subtype: 'text',
id: '3EB042FA6555',
from: '15815954040',
text: 'oi',
isgroup: false,
reply: { id: undefined },
participant: '',
timestamp: 1633147282
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'forwarding',
message: 'message of erro'
}
```## Get Chats
> List All Chats of Conversations
```javascript
let response = await client.getChats()```
Return with success
```javascript
{
session: 'Marketing',
type: 'get-chats',
chats: [
{ id: '556181590153', name: 'Joe Dutra', mute: '0', spam: 'false' },
{
id: '5511982743910-1596072761',
name: 'Venom Support',
mute: '0',
spam: 'false'
}
]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-chats',
message: 'message of erro'
}
```
## Read Chat Messages> Read all messages from a chat
```javascript
let response = await client.markReadAll('5561981590153')```
> Read message from a chat
```javascript
let response = await client.markRead('5561981590153', '3EB01A690E67') // params: Number, MessageID```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: "mark-read"
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'mark-read',
message: 'message of erro'
}
```
## Get All Contacts> List All Contacts
```javascript
let response = await client.getAllContacts()```
Return with success
```javascript
{
session: 'Marketing',
type: 'get-all-contacts',
qt: 2,
contacts: [
{
id: '552123919428',
name: 'Alenii Venom',
short: ''
},
{
id: '556181590153',
name: 'Joe Dutra',
short: ''
}
]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-all-contacts',
message: 'message of erro'
}
```
## Get Block List> List All Contacts Blocking
```javascript
let response = await client.getBlockList()```
Return with success
```javascript
{
session: 'Marketing',
type: 'get-block-list',
list: [ '5561986268199', '5561998745252' ]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-block-list',
message: 'message of erro'
}
```## Mute Chat
> Silence or remove the silence of a particular chat for a specific period
**Mute**
```javascript
//number of chat, timer: ['hour', 'week', 'ever']
let response = await client.muteChat("5561981590153", "hour")```
**Unmute**
```javascript
//number of chat
let response = await client.unmuteChat("5561981590153")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'mute-chat',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'mute-chat',
message: 'message of erro'
}
```
## Archive Chat> Archive or unarchive a specific chat
**Archive**
```javascript
//number of chat, true
let response = await client.archiveChat("5561981590153", true)```
**Unarchive**
```javascript
//number of chat, false
let response = await client.archiveChat("5561981590153", false)```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'archive-chat',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'archive-chat',
message: 'message of erro'
}
```
## Delete Chat> Delete a specific chat or group
**Archive**
```javascript
//number of chat or group
let response = await client.deleteChat("5561981590153")
```Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'delete-chat',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'delete-chat',
message: 'message of erro'
}
```
## Pin Chat> Pin or unpin a specific chat or group
**Pin**
```javascript
//number of chat, true
let response = await client.pinChat("5561981590153", true)```
**Unpin**
```javascript
//number of chat, false
let response = await client.pinChat("5561981590153", false)```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'pin-chat',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'pin-chat',
message: 'message of erro'
}
```
## Block Contact> Blocking or unblocking a specific contact
**Block**
```javascript
//number of chat
let response = await client.blockContact("5561981590153")```
**Unblock**
```javascript
//number of chat
let response = await client.unblockContact("5561981590153")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'block-contact',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'block-contact',
message: 'message of erro'
}
```
## Get Profile Status> Displays the text of the status of a specific contact
```javascript
//number of chat
let response = await client.getProfileStatus("5561981590153")```
Return with success
```javascript
{
session: 'Marketing',
type: 'get-profile-status',
status: 'Que Deus seja sempre louvado em nossas vidas'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-profile-status',
message: 'message of erro'
}
```
## Get Picture> Displays the image of a specific contact
```javascript
//number of chat
let response = await client.getPicture("5561981590153")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'get-picture',
picture: 'https://pps.whatsapp.net/v/t61.24694-24/166060433_390988636021500_3494454124066997603_n.jpg?ccb=11-4&oh=453e672ddc35e64ca123439f7a89d7d2&oe=615EAAAF'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-picture',
message: 'message of erro'
}
```
## Set Picture> Set image for profile or group
```javascript
//number of chat, file local path
let response = await client.setPicture("5561981590153", "./image-profile.png")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'set-picture'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'set-picture',
message: 'message of erro'
}
```
## Get Number Profile> Checks if a number exists in the WhastApp
```javascript
//number of chat
let response = await client.getNumberProfile("5561981590153")```
Return with success
```javascript
{
session: 'Marketing',
type: 'get-number-profile',
id: '556181590153',
isBusiness: false,
exist: true
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-number-profile',
message: 'message of erro'
}
```## Groups Functions
We created the easiest way to create groups with **Superchats**
## Create Group
> Create a group with participants
```javascript
//name of group, array with number of contacts
let response = await client.createGroup("Name Group", ["556181590153", "5561981819855"])```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'create-group',
groupId: "15815954040-1631239154"
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'create-group',
message: 'message of erro'
}
```## Add Participants Group
> Add participants in group
```javascript
//id of group, array with number of contacts
let response = await client.addParticipantsGroup("15815954040-1631239154", ["556181590153", "5561981819855"])```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'add-participants-group',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'add-participants-group',
message: 'message of erro'
}
```
## Add Admins Group> Add or Remove participants of group as admin
```javascript
//id of group, array with number of contacts
let response = await client.addGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"])```
```javascript
//id of group, array with number of contacts
let response = await client.removeGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"])```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'add-group-admins',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'add-group-admins',
message: 'message of erro'
}
```
## Change Name of Group> Change name of group
```javascript
//id of group, name group
let response = await client.groupTitle("15815954040-1631239154", "new name of group")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'group-title',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'group-title',
message: 'message of erro'
}
```
## Change Description of Group> Change description of group
```javascript
//id of group, name group
let response = await client.groupDescription("15815954040-1631239154", "description of group")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'group-description',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'group-description',
message: 'message of erro'
}
```
## Join Group> Join a group specified
```javascript
//id of group
let response = await client.joinGroup("15815954040-1631239154")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'join-group',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'join-group',
message: 'message of erro'
}
```
## Leave Group> Leaves a group specified
```javascript
//id of group
let response = await client.leaveGroup("15815954040-1631239154")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'leave-group',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'leave-group',
message: 'message of erro'
}
```## Revoke Group Link
> Revoke link from a specified group
```javascript
//id of group
let response = await client.revokeGroupLink("15815954040-1631239154")```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'revoke-group-link',
linkGroup: 'G3M81fQbuwDB2cuAdPIv0h'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'revoke-group-link',
message: 'message of erro'
}
```
## Info Group> Get info from a specified group
```javascript
//id of group
let response = await client.infoGroup("15815954040-1631239154")```
Return with success
```javascript
{
session: 'Marketing',
type: 'info-group',
status: 200,
id: '15795662985-1631581942',
owner: '[email protected]',
title: 'Teste Grupo Live',
create: 1631581942,
participants: [
{
id: '556181590153',
name: 'Joe Dutra',
short: 'Joe',
isAdmin: false,
isSuperAdmin: false
},
{
id: '5521991977392',
name: 'Israel - Fabrica de Sonhos',
short: 'Israel - Fabrica',
isAdmin: false,
isSuperAdmin: false
}
]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'info-group',
message: 'message of erro'
}
```
## Set Group Settings> Get info from a specified group
**Set sending messages in group only for admins**
```javascript
//id of group, type, boolean
let response = await client.setGroupSettings("15815954040-1631239154", "message", true)```
**Set change settings in group only for admins**
```javascript
//id of group, type, boolean
let response = await client.setGroupSettings("15815954040-1631239154", "settings", true)```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'set-group-settings',
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'set-group-settings',
message: 'message of erro'
}
```
## Get Groups List> Get all groups list
```javascript
let response = await client.getGroups()```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'get-groups',
chats: [
{ id: '5511982743910-1596072761', name: 'Venom Support' },
{ id: '556181590153-1625838636', name: 'Venom Business' }
]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-groups',
message: 'message of erro'
}
```## Get Host Device
> Get info of device
```javascript
let response = await client.getHostDevice()```
Return with success
```javascript
{
session: 'Marketing',
status: 200,
type: 'get-host-device',
phone: '556181590153',
image: "https://pps.whatsapp.net/v/t61.24694-24/254827313_500572874791871_6168181924916411415_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=5ee43eb4f1fe109b10ceba05292561aa&oe=622FF53D",
pushName: 'Joe Dutra'
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-host-device',
message: 'message of erro'
}
```
## Chat Messages Functions> Know the types of functions to recover chat messages
**Take the last 10 messages from a chat**
```javascript
//number of chat, Number
let response = await client.getChatMessages('556181590153', 10)```
**Take all messages from a chat**
```javascript
//number of chat
let response = await client.getChatAllMessages('556181590153')```
**Take all unread messages from all chats**
```javascript
let response = await client.getAllUnreadMessages()```
Return with success```javascript
{
session: 'Marketing',
type: 'get-chat-messages',
messages: [
{
session: 'Marketing',
type: 'reply',
subtype: 'text',
id: '3EB082EFA70F',
from: '556181590153',
text: 'Oi',
isgroup: false,
reply: [Object],
participant: '',
timestamp: 1633407729
},
{
session: 'Marketing',
type: 'text',
id: '3EB0D91B1ECF',
from: '556181590153',
content: 'Oi',
isgroup: false,
participant: '',
timestamp: 1633408611
},
{
session: 'Marketing',
type: 'text',
id: '3EB0AD7A246F',
from: '556181590153',
content: 'Testando',
isgroup: false,
participant: '',
timestamp: 1633411173
},
{
session: 'Marketing',
type: 'text',
id: '46110924F9C202D3933AA4CBC2F209A3',
from: '556181590153',
content: 'Oi',
isgroup: false,
participant: '',
timestamp: 1633411357
},
{
session: 'Marketing',
type: 'text',
id: '3EB0EE5900AF',
from: '556181590153',
content: 'Testando',
isgroup: false,
participant: '',
timestamp: 1633411382
},
{
session: 'Marketing',
type: 'text',
id: '96033721D4426073C37802F407251F9A',
from: '556181590153',
content: 'Oi',
isgroup: false,
participant: '',
timestamp: 1633411396
},
{
session: 'Marketing',
type: 'text',
id: '3EB067D84A06',
from: '556181590153',
content: 'Testando',
isgroup: false,
participant: '',
timestamp: 1633411746
},
{
session: 'Marketing',
type: 'text',
id: '2CDF9BAF7E20E72BC74D602A339DA2C2',
from: '556181590153',
content: 'Oiiii',
isgroup: false,
participant: '',
timestamp: 1633411781
},
{
session: 'Marketing',
type: 'text',
id: '4DEBB46473A8E642E8764F6C70567089',
from: '556181590153',
content: 'Como vai???',
isgroup: false,
participant: '',
timestamp: 1633411792
},
{
session: 'Marketing',
type: 'text',
id: 'B536EAE6275FD6FF98F3E3326FE1682F',
from: '556181590153',
content: 'Top',
isgroup: false,
participant: '',
timestamp: 1633411811
}
]
}
```
Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'get-chat-messages',
message: 'message of erro'
}
```## Update Presence
Update your presence for a certain contact
Types of state: a = available, c = composing, r = recording, p = paused
```javascript
//chat number, state: a, c, r, p
let response = await client.setPresence('556181590153', 'c');```
Return with success```javascript
{
session: 'Marketing',
status: 200,
type: 'set-presence'
}
```Return with erro
```javascript
{
session: 'Marketing',
status: 404,
type: 'set-presence',
message: 'message of erro'
}
```## Observation Events
> Follow each event at the time that happen
### **Received Message Event**
> Receive an event all the time you receive a message from some contact
```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onMessage: (event) => {
console.log(event)
})
```
Return of event onMessage```javascript
{
session: 'Marketing',
type: 'text',
id: '3EB07A5B9979E8CB453A',
from: '556181590153',
content: 'oiii',
isgroup: false,
participant: '',
timestamp: 1633414066
}
```### **Reading Confirmation Event**
> Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read
```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onAck: (event) => {
console.log(event)
})
```
Return of event onAck```javascript
{
session: 'Marketing',
status: 'RECEIVED',
type: 'text',
id: '3EB02BC6217B',
to: '556181590153',
text: 'Hii',
isgroup: false,
timestamp: 1633414317
}
```
### **Presence Event**> Receive an event every time a contact is: typing, recording, online or offline with you
Types of state: **available**, **composing**, **recording** and **paused**```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onPresence: (event) => {
console.log(event)
})```
Return of event onPresence```javascript
{
session: 'Marketing',
from: '556181590153',
status: 'composing',
pushname: 'Joe Dutra'
}
```
### **Group Event**> Receive events all time the name of a group, configurations are changed
Types of return: **change-name**, **change-messages-admin**, **change-settings-admin** and **paused**```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onGroups: (event) => {
console.log(event)
})
```
Return of event onGroup##### **Name change group**
```javascript
{
session: 'Marketing',
action: 'change-name',
changed: [ 'Grupo Live', 'Teste Grupo Live' ],
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '15795662985',
participants: 3
}
```##### **Group changes for messages just for admins**
```javascript
{
session: 'Marketing',
action: 'change-messages-admin',
changed: 'active',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '15795662985',
participants: 3
}
```
##### **Group changes for settings just for admins**
```javascript
{
session: 'Marketing',
action: 'change-settings-admin',
changed: 'active',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '15795662985',
participants: 3
}
```
### **Participants Event**> Receive events about group participants
Types of action: **add**, **remove**, **promote** and **demote**
```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onParticipants: (event) => {
console.log(event)
})```
Return of event onParticipants##### **Add participants**
```javascript
{
session: 'Marketing',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '5521991977392',
action: 'add',
participants: 3
}
```
##### **Remove participants**```javascript
{
session: 'Marketing',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '5521991977392',
action: 'remove',
participants: 2
}
```##### **Promote participants**
```javascript
{
session: 'Marketing',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '5521991977392',
action: 'promote',
participants: 3
}
```
##### **Demote participants**```javascript
{
session: 'Marketing',
group: 'Grupo Live',
from: '15795662985-1631581942',
participant: '5521991977392',
action: 'demote',
participants: 3
}
```
### **Delete Event**> Receive events every time a message is deleted
```javascript
//event:any
const client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
multidevice: true, // (default is false) for used whatsapp beta
onDelete: (event) => {
console.log(event)
})```
Return of event onDelete```javascript
{
session: 'Marketing',
type: 'message-delete',
from: '15795662985-1631581942',
id: '3EB07E88FDCF1C4EF887',
timestamp: 1633453902
}
```