Starting
Quick Start
Run the following command to ensure SuperChats is installed:
bash
$ npm install superchats
ou use yarn
bash
$ yarn add superchats
JavaScript Base Code Example
javascript
// Function for Javascript
const superchats = require("superchats");
async function start(){
let client = await superchats.create({
session: "Marketing",
license: "asjdh-efddff734-sdsdf834-233272",
driveStorage?: "local",
qr: false, // Brief
code?: true, // Brief
phoneNumber?: '5561985290357', // Brief
nodata?: true,
logQr?: false,
alwaysOn?: true,
autoRead?: true,
nodata?: true,
logQr?: true,
statusFind: async (status) => {
console.log(status)
},
pairing?: async (session, code) => {
console.log(`code: ${code}`);
},
qrcode: async (session, base64Img, asciiQR, urlCode) => {
console.log(asciiQR)
},
onAnyMessage?: 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', 'Thank you for using SuperChats!!!');
console.log(response);
})()
TypeScript Base Code Example
typescript
import { create, Types } from "superchats";
(async function(){
const superchats: Promise<Types> = await create('Marketing', {
license: 'asjdh-efddff734-sdsdf834-233272',
// Same parameters as the javascript example;
})
const resposta = (await superchats).sendText('0000000000000', 'Thank you for using SuperChats!!!')
console.log(await resposta)
})()