### Install @wppconnect-team/wppconnect nightly release Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/installation.md This snippet shows how to install the latest nightly build of the @wppconnect-team/wppconnect package directly from the GitHub releases. Nightly builds may contain the newest features but might be less stable. ```Bash npm i --save https://github.com/wppconnect-team/wppconnect/releases/download/nightly/wppconnect-nightly.tgz ``` -------------------------------- ### Install @wppconnect-team/wppconnect stable package Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/installation.md This snippet demonstrates how to install the stable version of the @wppconnect-team/wppconnect package using either npm or Yarn. This is the recommended method for most users. ```Bash npm i --save @wppconnect-team/wppconnect ``` ```Bash yarn add @wppconnect-team/wppconnect ``` -------------------------------- ### Initialize Wppconnect Client (ES6/CommonJS) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Demonstrates how to create and start a Wppconnect client using either ES6 import or CommonJS `require`. The `create` method returns a Promise that resolves to a `Whatsapp` client instance. ```javascript // Supports ES6 // import { create, Whatsapp } from '@wppconnect-team/wppconnect'; const wppconnect = require('@wppconnect-team/wppconnect'); wppconnect .create() .then((client) => client.start()) .catch((error) => console.log(error)); ``` -------------------------------- ### WPPConnect REST API Endpoints Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/rest/README.md Documents the available REST API endpoints for interacting with the WPPConnect library, including methods, paths, and required parameters for sending messages. ```APIDOC GET /getconnectionstatus Description: Checks the connection status with WhatsApp. POST /sendmessage Description: Sends a message via WhatsApp. Parameters: telnumber: string (required) - The recipient's phone number (e.g., "554190000000"). message: string (required) - The message content to be sent (e.g., "Envio de mensagem WPPCONNECT!!!!"). Request Body (JSON): { "telnumber": "string", "message": "string" } ``` -------------------------------- ### Save WPPConnect Session QR Code to File Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Provides an example of how to configure WPPConnect to capture the generated QR code as a base64 string, convert it into an image buffer, and save it as a PNG file, offering an alternative to terminal display. ```javascript const fs = require('fs'); const wppconnect = require('@wppconnect-team/wppconnect'); wppconnect .create({ session: 'sessionName', catchQR: (base64Qr, asciiQR) => { console.log(asciiQR); // Optional to log the QR in the terminal 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); } } ); }, logQR: false, }) .then((client) => client.start()) .catch((error) => console.log(error)); ``` -------------------------------- ### Send Message via cURL to WPPConnect REST API Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/rest/README.md Example cURL command to send a message to the WPPConnect REST API's /sendmessage endpoint. It demonstrates how to specify the content type and pass the JSON payload. ```bash curl --location --request POST 'http://127.0.0.1:3000/sendmessage' \ --header 'Content-Type: application/json' \ --data-raw '{ "telnumber": "554190000000", "message": "Envio de mensagem WPPCONNECT!!!!" }' ``` -------------------------------- ### Install WPPConnect npm package Source: https://github.com/wppconnect-team/wppconnect/blob/master/README.md This command installs the WPPConnect library as a dependency in your Node.js project. It uses npm, the Node.js package manager, to fetch and save the package to your 'node_modules' directory and update 'package.json'. ```bash npm i --save @wppconnect-team/wppconnect ``` -------------------------------- ### Initialize WPPConnect Client and Handle Incoming Messages Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/receiving-messages.md This JavaScript code snippet demonstrates how to set up and start a WPPConnect client. It includes a message listener that checks for incoming messages with the body 'Hello' and automatically sends a predefined text response back to the sender. Error handling for sending messages is also included. ```javascript // Supports ES6 // import { create, Whatsapp } from '@wppconnect-team/wppconnect'; const wppconnect = require('@wppconnect-team/wppconnect'); wppconnect .create() .then((client) => client.start()) .catch((error) => console.log(error)); function start(client) { client.onMessage((message) => { if (message.body === 'Hello') { client .sendText(message.from, 'Hello, how I may help you?') .then((result) => { console.log('Result: ', result); //return success object }) .catch((error) => { console.error('Error when sending: ', error); //return error object }); } }); client.start() } ``` -------------------------------- ### Start Typing Indicator using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Initiates the 'typing' indicator in a specified chat, signaling to the recipient that the user is currently composing a message. ```javascript await client.startTyping('000000000000@c.us'); ``` -------------------------------- ### Use a custom Winston logger with Wppconnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/configuring-logger.md This example shows how to integrate a custom Winston logger with Wppconnect Bot. It configures a logger to write error logs to 'error.log' and info logs to 'combined.log', then passes this custom logger to the `wppconnect.create` method. ```javascript // Supports ES6 // import * as wppconnect from '@wppconnect-team/wppconnect'; // import * as winston from 'winston'; const wppconnect = require('@wppconnect-team/wppconnect'); const winston = require('winston'); const logger = winston.createLogger({ level: 'info', format: winston.format.json(), defaultMeta: { service: 'user-service' }, transports: [ // // - Write all logs with level `error` and below to `error.log` // - Write all logs with level `info` and below to `combined.log` // new winston.transports.File({ filename: 'error.log', level: 'error' }), new winston.transports.File({ filename: 'combined.log' }), ], }); wppconnect .create({ session: 'sessionName', logger: logger, }) .then((client) => { client.start(); }) .catch((erro) => { console.log(erro); }); ``` -------------------------------- ### Configure Wppconnect Client with Advanced Options Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Shows how to pass various optional parameters to the `create` method for advanced client configuration. This includes handling QR code events, status updates, loading screens, headless mode, debugging, and session token management. ```javascript wppconnect.create({ session: 'sessionName', //Pass the name of the client you want to start the bot catchQR: (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); }, statusFind: (statusSession, session) => { console.log('Status Session: ', statusSession); //return isLogged || notLogged || browserClose || qrReadSuccess || qrReadFail || autocloseCalled || desconnectedMobile || deleteToken //Create session wss return "serverClose" case server for close console.log('Session name: ', session); }, onLoadingScreen: (percent, message) => { console.log('LOADING_SCREEN', percent, message); }, headless: true, // Headless Chrome devtools: false, // Open devtools by default useChrome: true, // If false will use Chromium instance debug: false, // Opens a debug session logQR: true, // Logs QR automatically in terminal browserWS: '', // If you want to use browserWSEndpoint browserArgs: [''], // Parameters to be added into the Chrome browser instance puppeteerOptions: {}, // Will be passed to puppeteer.launch disableWelcome: false, // Option to disable the welcoming message which appears in the beginning updatesLog: true, // Logs info updates automatically in terminal autoClose: 60000, // Automatically closes the wppconnect only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false) tokenStore: 'file', // Define how to work with tokens, which can be a custom interface folderNameToken: './tokens', //folder name when saving tokens // BrowserSessionToken // To receive the client's token use the function await client.getSessionTokenBrowser() sessionToken: { WABrowserId: '"UnXjH....."', WASecretBundle: '{"key":"+i/nRgWJ....","encKey":"kGdMR5t....","macKey":"+i/nRgW...."}', WAToken1: '"0i8...."', WAToken2: '"1@lPpzwC...."' } }) .then((client) => client.start()) .catch((error) => console.log(error)); ``` -------------------------------- ### Initialize WPPConnect Client with Status Callback Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Demonstrates how to initialize a WPPConnect client instance and register a `statusFind` callback to receive real-time updates on the session's connection status, logging the status and session name to the console. ```javascript const wppconnect = require('@wppconnect-team/wppconnect'); wppconnect .create({ session: 'sessionName', statusFind: (statusSession, session) => { // return: isLogged || notLogged || browserClose || qrReadSuccess || qrReadFail || autocloseCalled || desconnectedMobile || deleteToken console.log('Status Session: ', statusSession); // create session wss return "serverClose" case server for close console.log('Session name: ', session); }, }) .then((client) => client.start()) .catch((error) => console.log(error)); ``` -------------------------------- ### Wppconnect CreateOptions API Reference Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Defines the optional parameters available for the `wppconnect.create` method, allowing customization of session behavior, QR code handling, browser settings, and token management. ```APIDOC interface CreateOptions { session?: string; // Pass the name of the client you want to start the bot catchQR?: (base64Qrimg: string, asciiQR: string, attempts: number, urlCode: string) => void; statusFind?: (statusSession: string, session: string) => void; // statusSession: 'isLogged' | 'notLogged' | 'browserClose' | 'qrReadSuccess' | 'qrReadFail' | 'autocloseCalled' | 'desconnectedMobile' | 'deleteToken' | 'serverClose' onLoadingScreen?: (percent: number, message: string) => void; headless?: boolean; // Headless Chrome devtools?: boolean; // Open devtools by default useChrome?: boolean; // If false will use Chromium instance debug?: boolean; // Opens a debug session logQR?: boolean; // Logs QR automatically in terminal browserWS?: string; // If you want to use browserWSEndpoint browserArgs?: string[]; // Parameters to be added into the Chrome browser instance puppeteerOptions?: object; // Will be passed to puppeteer.launch disableWelcome?: boolean; // Option to disable the welcoming message which appears in the beginning updatesLog?: boolean; // Logs info updates automatically in terminal autoClose?: number | boolean; // Automatically closes the wppconnect only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false) tokenStore?: string; // Define how to work with tokens, which can be a custom interface folderNameToken?: string; // folder name when saving tokens sessionToken?: { WABrowserId: string; WASecretBundle: string; WAToken1: string; WAToken2: string; }; // BrowserSessionToken } ``` -------------------------------- ### Create Multiple Wppconnect Sessions Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Illustrates how to initialize multiple Wppconnect client sessions, such as 'sales' and 'support', by specifying a unique `session` name in the `create` method options. This allows managing separate bot instances. ```javascript // Init sales WhatsApp bot wppconnect.create({session: 'sales'}).then((client) => client.start()); // Init support WhatsApp bot wppconnect.create({session: 'support'}).then((client) => client.start()); ``` -------------------------------- ### Configure WPPConnect for Multidevice Support Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Explains how to enable multidevice functionality in WPPConnect by specifying a fixed `userDataDir` within `puppeteerOptions`, ensuring persistent login for the browser session as required by WhatsApp's authentication changes. ```javascript wppconnect .create({ // ... session: 'mySessionName', puppeteerOptions: { userDataDir: './tokens/mySessionName', // or your custom directory }, // ... }) .then((client) => client.start()) .catch((error) => console.log(error)); ``` -------------------------------- ### Build WPPConnect project for development Source: https://github.com/wppconnect-team/wppconnect/blob/master/README.md This command executes the build script defined in the project's 'package.json' file. It compiles and prepares the WPPConnect project for development or distribution, typically generating optimized code. ```bash npm run build ``` -------------------------------- ### WPPConnect Session Status Callback Conditions Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Defines the possible status values returned by the `statusFind` callback in WPPConnect, along with their corresponding conditions, indicating the state of the WhatsApp session. ```APIDOC | 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 disconnected in to mobile | | `serverClose` | Client has disconnected in to wss | | `deleteToken` | If you pass true within the function `client.getSessionTokenBrowser(true)` | ``` -------------------------------- ### Bot Command: !info Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Requests connection information from the bot. ```APIDOC !info ``` -------------------------------- ### Send Image as Sticker using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Generates a sticker from a given image (PNG, JPG, WebP, or URL) and sends it to a specified chat. The method returns a promise that resolves with a success object or rejects with an error object. ```javascript await client .sendImageAsSticker('000000000000@c.us', './image.jpg') .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Control WPPConnect Phone Connection Watchdog Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/creating-client.md Illustrates how to enable and disable the phone connection watchdog feature in WPPConnect, allowing users to specify a custom interval for monitoring the connection status or use the default setting. ```javascript // To start with default interval. client.startPhoneWatchdog(); // To start with custom interval. client.startPhoneWatchdog(30000); // 30s // To stop. client.stopPhoneWatchdog(); ``` -------------------------------- ### Bot Command: !ping reply Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Sends a ping command with a 'reply' argument. The bot responds with 'pong like reply'. ```APIDOC !ping reply ``` -------------------------------- ### Send Video as GIF using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a video file to a specified chat, converting it into a GIF. This function requires the chat ID, the path to the video file, and optionally a file name and caption for the GIF. ```javascript await client.sendVideoAsGif( '000000000000@c.us', 'path/to/video.mp4', 'video.gif', 'Gif image file' ); ``` -------------------------------- ### Bot Command: !ChatState Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Changes the chat's state to typing, recording, or paused based on the provided numerical option (0 for Typing, 1 for Recording, 2 for Paused). ```APIDOC !ChatState < 0: Typing or 1: Recording or 2: Paused > ``` -------------------------------- ### Bot Command: !location Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Instructs the bot to send its current location. ```APIDOC !location ``` -------------------------------- ### Send Message with Options using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a message to a specified chat with additional configuration options, such as quoting a previous message. The method returns a promise that resolves upon successful delivery or rejects if an error occurs. ```javascript await client .sendMessageOptions( '000000000000@c.us', 'This is a reply!', { quotedMessage: message.id, } ) .then((result) => { console.log(result); }) .catch((e) => { console.log(e); }); ``` -------------------------------- ### Bot Command: !ping Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Sends a ping command to the bot. The bot responds with 'pong'. ```APIDOC !ping ``` -------------------------------- ### Bot Command: !pin Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Pins or unpins the current chat based on the boolean argument. 'true' freezes the chat, 'false' unfreezes it. ```APIDOC !pin ``` -------------------------------- ### Bot Command: !chats Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Requests the total number of opened chats from the bot. ```APIDOC !chats ``` -------------------------------- ### Bot Command: !sendto Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Sends a message to a specified number. Requires a phone number and the message content as arguments. ```APIDOC !sendto ``` -------------------------------- ### Send Animated Sticker from GIF (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Generates and sends an animated sticker from a provided GIF image to a specified chat ID. A valid GIF and WebP image are required, and it can be sent via local path or HTTP/HTTPS URL. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendImageAsStickerGif('000000000000@c.us', './image.gif') .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Configure Wppconnect default logger to log to file Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/configuring-logger.md This snippet illustrates how to modify the default Wppconnect logger to save logs to a file using Winston's file transport. It also shows how to add and remove custom console transports. ```javascript // Supports ES6 // import * as wppconnect from '@wppconnect-team/wppconnect'; // import * as winston from 'winston'; const wppconnect = require('@wppconnect-team/wppconnect'); const winston = require('winston'); // Optional: Remove all default transports wppconnect.defaultLogger.clear(); // Remove all transports // Create a file transport const files = new winston.transports.File({ filename: 'combined.log' }); wppconnect.defaultLogger.add(files); // Add file transport //Optional: create a custom console with error level const console = new winston.transports.Console({ level: 'error' }); wppconnect.defaultLogger.add(console); // Add console transport //Optional: Remove the custom transport wppconnect.defaultLogger.remove(console); // Remove console transport ``` -------------------------------- ### Bot Command: !typing Source: https://github.com/wppconnect-team/wppconnect/blob/master/examples/bot-functions/README.md Changes the chat's typing state. 'true' sets the chat to typing, 'false' removes the typing indicator. ```APIDOC !typing ``` -------------------------------- ### Send Link Preview Message (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Automatically sends a link with an auto-generated link preview to a specified chat ID. A custom message can also be added. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendLinkPreview( '000000000000@c.us', 'https://www.youtube.com/watch?v=V1bFr2SWP1I', 'Kamakawiwo ole' ) .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Send File from Base64 (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a file encoded in Base64 format to a specified chat ID. The Base64 string must include the mime type. It includes a file name and an optional caption. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendFileFromBase64( '000000000000@c.us', base64PDF, 'file_name.pdf', 'See my file in pdf' ) .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Send Image Message (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends an image from a local path or a valid HTTP protocol URL to a specified chat ID. It includes an image name and an optional caption. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendImage( '000000000000@c.us', 'path/to/img.jpg', 'image-name', 'Caption text' ) .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Configure Wppconnect default logger level Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/configuring-logger.md This snippet demonstrates how to change the default log level of Wppconnect Bot's logger and how to silence console logging. It uses the `wppconnect.defaultLogger` instance, which is based on winston. ```javascript // Supports ES6 // import * as wppconnect from '@wppconnect-team/wppconnect'; const wppconnect = require('@wppconnect-team/wppconnect'); // Levels: 'error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly' // All logs: 'silly' wppconnect.defaultLogger.level = 'silly'; // If you want to stop console logging wppconnect.defaultLogger.transports.forEach((t) => (t.silent = true)); ``` -------------------------------- ### Send File Message (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a file from a local path or a valid HTTP protocol URL to a specified chat ID. WPPConnect automatically handles mime types. It includes a file name and an optional caption. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendFile( '000000000000@c.us', 'path/to/file.pdf', 'file_name', 'See my file in pdf' ) .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Set Chat State using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sets the current state of a specified chat. This can be used to indicate various activities such as typing (0), recording (1), or paused (2). ```javascript await client.setChatState('000000000000@c.us', 0 | 1 | 2); ``` -------------------------------- ### Send List of Contact Vcards (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a list of contact cards to a specified chat ID. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendContactVcardList('000000000000@c.us', [ '111111111111@c.us', '222222222222@c.us' ]) .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Send Mentioned Message with WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a message that includes mentions to specific contacts. This function requires the chat ID, the message content (with @tags), and an array of the mentioned contact IDs. ```javascript await client.sendMentioned( '000000000000@c.us', 'Hello @5218113130740 and @5218243160777!', ['5218113130740', '5218243160777'] ); ``` -------------------------------- ### Reply to a Message with Mentions using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a text message as a reply to a specific message, incorporating mentions of other contacts. Mentions can either be automatically detected from the message text or manually supplied via a list of contact IDs. ```javascript await client.sendText( '000000000000@c.us', 'Hello @5218113130740 and @5218243160777! This is a reply with mention!', { quotedMsg: message.id.toString(), detectMentioned: true, //either automatically detect the mentions mentionedList: ['5218113130740', '5218243160777'] //or supply them manually } ); ``` -------------------------------- ### Mark Chat as Seen using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Marks all messages in a specified chat as 'seen', indicating that they have been read by the user. ```javascript await client.sendSeen('000000000000@c.us'); ``` -------------------------------- ### Forward Messages using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Forwards one or more existing messages to a specified chat. This function requires the destination chat ID, an array of message IDs to be forwarded, and a boolean to control whether the original sender's information is visible. ```javascript await client.forwardMessages( '000000000000@c.us', [message.id.toString()], true ); ``` -------------------------------- ### Reply to a Message using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a text message as a direct reply to a specific message. This method requires the recipient's chat ID, the message content, and the ID of the message to which the reply is directed. ```javascript await client.sendText( '000000000000@c.us', 'This is a reply!', { quotedMsg: message.id.toString() } ); ``` -------------------------------- ### Send Single Contact Vcard (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a single contact card to a specified chat ID. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendContactVcard('000000000000@c.us', '111111111111@c.us', 'Name of contact') .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Send Location Message (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a geographical location with latitude, longitude, and a name to a specified chat ID. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendLocation('000000000000@c.us', '-13.6561589', '-69.7309264', 'Brasil') .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Send Basic Text Message (JavaScript) Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Sends a simple text message to a specified chat ID. The `chatId` can be a phone number for a user (`@c.us`) or a group ID (`-@g.us`). The function returns a success object on completion or an error object if sending fails. ```javascript await client .sendText('000000000000@c.us', '👋 Hello from wppconnect!') .then((result) => { console.log('Result: ', result); //return object success }) .catch((erro) => { console.error('Error when sending: ', erro); //return object error }); ``` -------------------------------- ### Stop Typing Indicator using WPPConnect Source: https://github.com/wppconnect-team/wppconnect/blob/master/docs/getting-started/basic-functions.md Stops the 'typing' indicator in a specified chat, removing the visual cue that the user is composing a message. ```javascript await client.stopTyping('000000000000@c.us'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.