### Example: Get Products from Catalog Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.catalog.getProducts Illustrates how to call the `getProducts` function using the `WPP.catalog` namespace to fetch a specified quantity of products for a given contact's catalog. ```TypeScript await WPP.catalog.getProducts('5521985625689@c.us', 10); ``` -------------------------------- ### Example: Get Order Information using WPP.order.get Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.order.get Demonstrates how to call the `WPP.order.get()` function to retrieve order details. ```JavaScript const orderInfo = await WPP.order.get(); ``` -------------------------------- ### JavaScript Example: Calling WPP.chat.getNotes Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.chat.getNotes Illustrates a call to the `WPP.chat.getNotes` function. Note that the example includes a second string argument, which is not part of the documented `getNotes` signature, suggesting a potential discrepancy or an example for a different overload/function. ```javascript WPP.chat.getNotes('[number]@c.us', 'Text for your notes'); ``` -------------------------------- ### WPP.call.offer JavaScript Examples Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.call.offer Examples demonstrating how to use the `WPP.call.offer` function to send different types of call offers, including basic voice calls and video calls, using the WPPConnect library. ```javascript // Send a call offer WPP.call.offer('[number]@c.us'); // Send a video call offer WPP.call.offer('[number]@c.us', {isVideo: true}); ``` -------------------------------- ### JavaScript Example: Calling getAllGroups Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.group.getAllGroups An example demonstrating how to call the `getAllGroups` function using the WPP object to retrieve all groups. ```JavaScript WPP.group.getAllGroups(); ``` -------------------------------- ### JavaScript: Examples for WPP.call.accept Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.call.accept Provides JavaScript examples demonstrating how to accept any incoming call or a specific call using its ID, and how to integrate with the `call.incoming_call` event. ```javascript // Accept any incoming call WPP.call.accept(); // Accept specific call id WPP.call.accept(callId); // Accept any incoming call WPP.on('call.incoming_call', (call) => { setTimeout(() => { WPP.call.accept(call.id); }, 1000); }); ``` -------------------------------- ### JavaScript Example: Join or Leave WhatsApp Web Beta Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.conn.joinWebBeta Examples demonstrating how to use the `WPP.conn.joinWebBeta` function in JavaScript to either join or leave the WhatsApp Web beta program. ```javascript // For join on Beta WPP.conn.joinWebBeta(true); // For leave of Beta WPP.conn.joinWebBeta(true); ``` -------------------------------- ### API Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.NetworkStatusModel Documents the initialize method, which performs initial setup for the model. This method is inherited from the Model class. ```APIDOC initialize(): void Returns: void Inherited from: Model.initialize Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### JavaScript Example: Get Contact Status Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.contact.getStatus Demonstrates how to use the `WPP.contact.getStatus` function to retrieve the status of a contact by their ID. The example shows an asynchronous call to get the status for a specific contact. ```JavaScript await WPP.contact.getStatus('[number]@c.us'); ``` -------------------------------- ### Promote Participants in WPP.community (JavaScript Example) Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.community.promoteParticipants An example demonstrating how to use the `promoteParticipants` function with `WPP.community` to promote a single participant to admin within a specified community using their IDs. ```JavaScript await WPP.community.promoteParticipants('123456@g.us', '123456@c.us'); ``` -------------------------------- ### initialize Method Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ReplyButtonModel Documentation for the 'initialize' method, inherited from 'Model'. This method initializes the model. ```APIDOC initialize(): void Returns: void Inherited from Model.initialize Defined in node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### JavaScript: Get Newsletter Subscribers Example Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.newsletter.getSubscribers Example usage of the `WPP.newsletter.getSubscribers` function to retrieve subscribers for a specific newsletter ID in JavaScript. ```JavaScript const code = WPP.newsletter.getSubscribers('[newsletter-id]@newsletter'); ``` -------------------------------- ### JavaScript Example: Get Community Participants Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.community.getParticipants Example usage of the `getParticipants` function in JavaScript to retrieve participants for a specific community ID. ```JavaScript await WPP.community.getParticipants('123456@g.us'); ``` -------------------------------- ### API Documentation for WPPConnect create function Source: https://wppconnect.io/wppconnect/modules.html/functions/create Detailed API documentation for the `create` function, used to start a WPPConnect bot session. It includes two distinct overloads for initialization, one using a `CreateOptions` object and another using individual session parameters and callbacks. The documentation covers parameters, return values, and deprecation status. ```APIDOC Function: create Overload 1: Signature: create(createOption: CreateOptions): Promise Description: Start the bot Parameters: createOption: CreateOptions Returns: Promise - Whatsapp page, with this parameter you will be able to access the bot functions Overload 2: Signature: create(sessionName: string, catchQR?: CatchQRCallback, statusFind?: StatusFindCallback, onLoadingScreen?: LoadingScreenCallback, catchLinkCode?: LinkByCodeCallback, options?: CreateConfig, browserSessionToken?: SessionToken): Promise Description: Start the bot. You must pass a string type parameter, this parameter will be the name of the client's session. If the parameter is not passed, the section name will be "session". Parameters: sessionName: string catchQR?: CatchQRCallback (Optional) statusFind?: StatusFindCallback (Optional) onLoadingScreen?: LoadingScreenCallback (Optional) catchLinkCode?: LinkByCodeCallback (Optional) options?: CreateConfig (Optional) browserSessionToken?: SessionToken (Optional) Returns: Promise - Whatsapp page, with this parameter you will be able to access the bot functions Deprecated: Deprecated in favor of create with CreateOptions (e.g., wppconnect.create({session: 'test'})). ``` -------------------------------- ### Initialize Model API Reference Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ContactModel Documents the `initialize` method, which performs initial setup for the model. It takes no parameters and returns void. ```APIDOC initialize(): void Returns: void Inherited from: Model ``` -------------------------------- ### Example: Get Past Participants for a Group (JavaScript) Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.group.getPastParticipants An example demonstrating how to use the `WPP.group.getPastParticipants` function to retrieve past participants of a specified group ID. ```JavaScript WPP.group.getPastParticipants('[group-id]@g.us'); ``` -------------------------------- ### API Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.QuickReplyModel Initializes the Model instance. This method is typically called during the object's lifecycle to set up its initial state. ```APIDOC initialize(): void Returns: void Inherited from Model ``` -------------------------------- ### JavaScript Example: Get Business Profile Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.contact.getBusinessProfile Example demonstrating how to use the `getBusinessProfile` function in JavaScript to retrieve a contact's business profile. ```JavaScript const url = await WPP.contact.getBusinessProfile('[number]@c.us'); ``` -------------------------------- ### JavaScript Example: Check WPP.conn Main Ready Status Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.conn.isMainReady Example demonstrating how to call the `isMainReady` function using `WPP.conn` to determine if the main WPPConnect interface is ready. ```JavaScript const isMainReady = WPP.conn.isMainReady(); ``` -------------------------------- ### get Method Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ReplyButtonModel Documentation for the 'get' method, inherited from 'Model'. This method retrieves an attribute from the ReplyButtonModel. ```APIDOC get(attr: T): ReplyButtonModel[T] Type Parameters: T extends keyof ReplyButtonModel Parameters: attr: T Returns: ReplyButtonModel[T] Inherited from Model.get Defined in node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:54 ``` -------------------------------- ### WPPConnect CreateConfig Interface API Reference Source: https://wppconnect.io/wppconnect/modules.html/interfaces/CreateConfig Detailed API documentation for the `CreateConfig` interface, which defines all configurable options for initializing a WPPConnect client. Each property's type, description, and default value (if applicable) are provided. ```TypeScript interface CreateConfig { autoClose?: number; browser?: Browser | BrowserContext; browserArgs?: string[]; browserWS?: string; createPathFileToken?: boolean; debug?: boolean; deviceName?: string | false; deviceSyncTimeout?: number; devtools?: boolean; disableGoogleAnalytics?: boolean; disableWelcome?: boolean; folderNameToken?: string; googleAnalyticsId?: string; headless?: boolean | "shell"; linkPreviewApiServers?: string[]; logger?: Logger; logQR?: boolean; mkdirFolderToken?: string; page?: Page; phoneNumber?: string; poweredBy?: string; proxy?: { password: string; url: string; username: string }; puppeteerOptions?: LaunchOptions; sessionToken?: SessionToken; tokenStore?: string | TokenStore; updatesLog?: boolean; useChrome?: boolean; waitForLogin?: boolean; whatsappVersion?: string; } ``` ```APIDOC Property: autoClose Type: number Optional: Yes Description: Automatically closes the wppconnect only when scanning the QR code (default 60000 miliseconds, if you want to turn it off, assign 0 or false) Default: 60000 ``` ```APIDOC Property: browser Type: Browser | BrowserContext Optional: Yes Description: Pass a external browser instance, can be used with electron ``` ```APIDOC Property: browserArgs Type: string[] Optional: Yes Description: Parameters to be added into the chrome browser instance ``` ```APIDOC Property: browserWS Type: string Optional: Yes Description: If you want to use browserWSEndpoint ``` ```APIDOC Property: createPathFileToken Type: boolean Optional: Yes Description: Creates a folder when inserting an object in the client's browser, to work it is necessary to pass the parameters in the function create browserSessionToken Deprecated: See tokenStore Default: true ``` ```APIDOC Property: debug Type: boolean Optional: Yes Description: Opens a debug session Default: false ``` ```APIDOC Property: deviceName Type: string | false Optional: Yes Description: Define the connected device name in WhatsApp app ``` -------------------------------- ### WPPConnect: Example of getting a contact by ID Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.contact.get Demonstrates how to use the `WPP.contact.get` function to retrieve a contact by their ID, typically provided in the format '[number]@c.us'. ```JavaScript await WPP.contact.get('[number]@c.us'); ``` -------------------------------- ### JavaScript Example: Promote Single or Multiple Group Members Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.group.promoteParticipants Practical JavaScript examples demonstrating how to use `WPP.group.promoteParticipants` to promote group members to admin. The first example shows promoting a single member, while the second illustrates promoting multiple members by passing an array of participant IDs. ```JavaScript // One member await WPP.group.promoteParticipants('123456@g.us', '123456@c.us'); // More than one member await WPP.group.promoteParticipants('123456@g.us', ['123456@c.us','123456@c.us']); ``` -------------------------------- ### JavaScript: Get Group Invite Code Example Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.group.getInviteCode Example demonstrating how to use the `WPP.group.getInviteCode` function to retrieve a group's invite code and construct a WhatsApp chat link. ```javascript const code = WPP.group.getInviteCode('[group-id]@g.us'); const link = 'https://chat.whatsapp.com/' + code; ``` -------------------------------- ### API: initialize Method Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.AttachMediaModel Documents the `initialize` method, inherited from the `Model` class. This method takes no parameters and returns nothing. ```APIDOC initialize(): void Returns: void Inherited from: Model Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### JavaScript: Get Common Groups Example (WPPConnect) Source: https://wppconnect.io/wppconnect/modules.html/classes/Whatsapp Example demonstrating how to use the 'getCommonGroups' method to retrieve group IDs shared with a contact. ```JavaScript const groups_ids = await client.getCommonGroups('[number]@c.us'); ``` -------------------------------- ### API Documentation for startWebComms Function Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.whatsapp.websocket.startWebComms Documents the `startWebComms` function, which is responsible for initiating web communications. It is an asynchronous function that returns a Promise, resolving upon successful establishment of communication. ```APIDOC startWebComms(): Promise Returns: Promise Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/websocket/startWebComms.d.ts:19 ``` -------------------------------- ### JavaScript: Get Current Profile Name Example Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.profile.getMyProfileName This JavaScript example demonstrates how to call the `getMyProfileName` function from the `WPP.profile` module to obtain the current user's profile name and store it in a variable. ```javascript const myProfileName = WPP.profile.getMyProfileName(); ``` -------------------------------- ### Initialize Model Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.HistorySyncProgressModel Initializes the model. This method performs necessary setup and returns void upon completion. ```APIDOC initialize(): void Returns void Inherited from Model ``` -------------------------------- ### initializeLabels Function API Reference Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.whatsapp.functions.initializeLabels Provides the API documentation for the `initializeLabels` function, detailing its signature, parameters, return type, and the file where it is defined. ```APIDOC Function: initializeLabels Signature: initializeLabels(e: any): Promise Parameters: e: Type: any Returns: Type: Promise Source: node_modules/@wppconnect/wa-js/dist/whatsapp/functions/addToLabelCollection.d.ts:21 ``` -------------------------------- ### JavaScript Example: Get WhatsApp Contact Profile Picture URL Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.contact.getProfilePictureUrl Example demonstrating how to use the `WPP.contact.getProfilePictureUrl` function in JavaScript to fetch the profile picture URL for a specified WhatsApp contact ID. ```JavaScript const url = await WPP.contact.getProfilePictureUrl('[number]@c.us'); ``` -------------------------------- ### Configure linkPreviewApiServers Source: https://wppconnect.io/wppconnect/modules.html/interfaces/CreateConfig Allows setting custom API servers for link preview functionality. Defaults to null. ```APIDOC linkPreviewApiServers?: string[] Default: null ``` -------------------------------- ### Get Active Chat (API Definition & JavaScript Example) Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.chat.getActiveChat Provides the API definition for the `getActiveChat` function, detailing its purpose and return type, alongside a practical JavaScript example demonstrating how to retrieve the active chat and send a message. ```APIDOC getActiveChat(): ChatModel Description: Return the current active chat Returns: Type: ChatModel Description: The current active chat or undefined for none ``` ```javascript // Get active chat const chat = WPP.chat.getActiveChat(); WPP.chat.sendTextMessage(chat.id, 'Hi'); ``` -------------------------------- ### Listen to Event and Immediately Run Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductImageCollection Registers a listener for an event and immediately invokes the listener with the current event state, binding it to a provided context. ```APIDOC listenToAndRun(context: any, eventName: Event, listener?: Listener): this Parameters: context: any The value of `this` provided for the call to `listener` eventName: Event The name of the event. Optional listener: Listener The callback function. Returns: this Inherited from: Collection.listenToAndRun Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/misc/EventEmitter.d.ts:79 ``` -------------------------------- ### Example: Get Order Information Source: https://wppconnect.io/wppconnect/modules.html/classes/Whatsapp Demonstrates how to fetch details of a specific order using its message ID. ```JavaScript const orderInfo = await client.getOrder(''); ``` -------------------------------- ### API Reference: start Method Source: https://wppconnect.io/wppconnect/modules.html/classes/Whatsapp Initializes the WPPConnect client. This method is inherited from BusinessLayer.start. ```APIDOC start(): Promise ``` -------------------------------- ### JavaScript Example: Get and Log Current Device ID Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.conn.getMyDeviceId This example demonstrates how to call `WPP.conn.getMyDeviceId()` to retrieve the current logged user's device ID. The returned `Wid` object is then converted to a string and logged to the console, typically showing a format like 'ID:DeviceID@c.us'. ```JavaScript const wid = WPP.conn.getMyDeviceId(); console.log(wid.toString()); // Output: 123:4@c.us ``` -------------------------------- ### initialize Method API Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductImageModel Initializes the model. This method is inherited from Model and takes no parameters. ```APIDOC initialize(): void Returns: void Inherited from: Model Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### Example: Get Community Announcement Group in JavaScript Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.community.getAnnouncementGroup Demonstrates how to call the `getAnnouncementGroup` function using a community ID string to retrieve the announcement group. ```JavaScript WPP.community.getAnnouncementGroup('123456@g.us'); ``` -------------------------------- ### Overview of tokenStore Namespace API Source: https://wppconnect.io/wppconnect/modules.html/modules/tokenStore This section provides a high-level overview of the `tokenStore` namespace, listing all its public classes, interfaces, variables, and functions. It serves as an entry point to understand the available components for token management within the `@wppconnect-team/wppconnect` library. ```APIDOC Namespace: tokenStore Classes: - FileTokenStore - MemoryTokenStore Interfaces: - FileTokenStoreOptions - SessionToken - TokenStore Variables: - defaultFileTokenStoreOptions Functions: - isValidSessionToken - isValidTokenStore ``` -------------------------------- ### JavaScript Example: Get Current WhatsApp Catalog Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.catalog.getMyCatalog Demonstrates how to asynchronously retrieve the current user's WhatsApp catalog using the `WPP.catalog.getMyCatalog()` function. ```JavaScript // Get your current catalog const myCatalog = await WPP.catalog.getMyCatalog(); ``` -------------------------------- ### JavaScript Example: Get Current User Status Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.profile.getMyStatus Demonstrates how to asynchronously retrieve the current user's text status using the WPP.profile API in JavaScript. ```JavaScript await WPP.profile.getMyStatus(); ``` -------------------------------- ### ProductCollCollection Class API Reference Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductCollCollection Detailed API specification for the `ProductCollCollection` class, including its inheritance, constructor signature, the complex `findFirst` property with its overloads and descriptions, and a comprehensive list of all available methods and accessors. ```APIDOC Class ProductCollCollection Hierarchy: Collection -> ProductCollCollection Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/collections/ProductCollCollection.d.ts:21 Constructors: constructor(e?: any, t?: { parent: any }): ProductCollCollection Parameters: e: any (Optional) t: { parent: any } (Optional) Returns: ProductCollCollection Inherited from: Collection.constructor Properties: findFirst: { ( predicate: (value: ProductCollModel, index: number, obj: ProductCollModel[]) => value is S, thisArg?: any ): S Description: Returns the value of the first element in the array where predicate is true, and undefined otherwise. Type Parameters: S extends ProductCollModel Parameters: predicate: (value: ProductCollModel, index: number, obj: ProductCollModel[]) => value is S find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined. thisArg?: any (Optional) If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. Returns: S ( predicate: (value: ProductCollModel, index: number, obj: ProductCollModel[]) => unknown, thisArg?: any ): ProductCollModel Parameters: predicate: (value: ProductCollModel, index: number, obj: ProductCollModel[]) => unknown thisArg?: any (Optional) Returns: ProductCollModel } modelClass: any comparator: any model: any staleCollection?: boolean Accessors: length: number Methods: add assertGet at bind emit every filter findCollectionProducts findCollectionsList forEach get getCollectionModels getModelsArray head includes indexOf isListening isModel last lastIndexOf listenTo listenToAndRun listenToOnce map off on once reduce remove removeAllListeners removeListener reorder reorderMutate replaceId reset serialize set slice some sort stopListening toArray toJSON trigger unbind where ``` -------------------------------- ### JavaScript Examples for sendChargeMessage Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.chat.sendChargeMessage Practical JavaScript code examples demonstrating how to use `sendChargeMessage` for various scenarios, such as sending charges with product IDs, custom items, and integrating payment options like Pix. ```JavaScript // Send charge with a product WPP.chat.sendChargeMessage('[number]@c.us', [ { type: 'product', id: '67689897878', qnt: 2 }, { type: 'product', id: '37878774457', qnt: 1 } ]); // Send charge with a custom item WPP.chat.sendChargeMessage('[number]@c.us', [ { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 } ]); // Send charge with custom options WPP.chat.sendChargeMessage('[number]@c.us', [ { type: 'product', id: '37878774457', qnt: 1 }, { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 } ], { tax: 10000, shipping: 4000, discount: 10000 }); // Send charge with Pix data (auto generate copy-paste pix code) WPP.chat.sendChargeMessage('[number]@c.us', [ { type: 'custom', name: 'Item de cost test', price: 120000, qnt: 2 } ], { tax: 10000, shipping: 4000, discount: 10000, pix: { keyType: 'CPF', key: '00555095999', name: 'Name of seller' } }); ``` -------------------------------- ### JavaScript Example: Get Current User ID Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.conn.getMyUserId Demonstrates how to use the `WPP.conn.getMyUserId()` method to retrieve the current user's WhatsApp ID and log it to the console. ```JavaScript const wid = WPP.conn.getMyUserId(); console.log(wid.toString()); // Output: 123@c.us ``` -------------------------------- ### API Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.StickerModel Initializes the model. This method is typically called internally during object creation or setup. ```APIDOC Method: initialize Signature: initialize(): void Returns: void Inherited From: Model.initialize Defined In: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### Example: Get Group Size Limit using WPP.group Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.group.getGroupSizeLimit Demonstrates how to asynchronously retrieve and log the maximum group size limit using the `WPP.group.getGroupSizeLimit()` function from the WPPConnect library. ```javascript const limit = await WPP.group.getGroupSizeLimit(); console.log(limit); ``` -------------------------------- ### Configure page Source: https://wppconnect.io/wppconnect/modules.html/interfaces/CreateConfig Allows passing an external Page instance, useful for integration with environments like Electron. ```APIDOC page?: Page ``` -------------------------------- ### WPP.labels.editLabel Usage Examples Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.labels.editLabel Examples demonstrating how to use `WPP.labels.editLabel` to modify a label, showing basic usage, setting a label color with a hex code, and setting a label color with an index. ```JavaScript await WPP.labels.editLabel(`Name of label`); //or await WPP.labels.editLabel(`Name of label`, { labelColor: '#dfaef0' }); ``` ```JavaScript //or with color index await WPP.labels.editLabel(`Name of label`, { labelColor: 16 }); ``` -------------------------------- ### JavaScript Example: Get Platform from Message ID Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.chat.getPlatformFromMessage Demonstrates how to use the `WPP.chat.getPlatformFromMessage` function in JavaScript to retrieve the platform (e.g., Android, iPhone, Web) associated with a specific message ID. ```javascript // to get platform from a message const platform = WPP.chat.getPlatformFromMessage('[message_id]'); ``` -------------------------------- ### API: listenToAndRun Method Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.AttachMediaModel Documents the `listenToAndRun` method, inherited from the `Model` class. This method sets up an event listener and immediately runs the listener. ```APIDOC listenToAndRun(context: any, eventName: Event, listener?: Listener): this Parameters: context: any - The value of `this` provided for the call to `listener` eventName: Event - The name of the event. listener: Listener (Optional) - The callback function. Returns: this Inherited from: Model Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/misc/EventEmitter.d.ts:79 ``` -------------------------------- ### JavaScript Examples: Fetching Chat Messages with getMessages Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.chat.getMessages Practical JavaScript examples demonstrating how to use `WPP.chat.getMessages` to retrieve messages from a chat, including filtering by count, unread status, message ID, and various media types. ```JavaScript // Some messages WPP.chat.getMessages('[number]@c.us', { count: 20, }); // All messages WPP.chat.getMessages('[number]@c.us', { count: -1, }); // Last 20 unread messages WPP.chat.getMessages('[number]@c.us', { count: 20, onlyUnread: true, }); // All unread messages WPP.chat.getMessages('[number]@c.us', { count: -1, onlyUnread: true, }); // 20 messages before specific message WPP.chat.getMessages('[number]@c.us', { count: 20, direction: 'before', id: '' }); // Only media messages (url, document and links) WPP.chat.getMessages('[number]@c.us', { count: 20, media: 'all', }); // Only image messages WPP.chat.getMessages('[number]@c.us', { count: 20, media: 'image', }); // Only document messages WPP.chat.getMessages('[number]@c.us', { count: 20, media: 'document', }); // Only link (url) messages WPP.chat.getMessages('[number]@c.us', { count: 20, media: 'url', }); ``` -------------------------------- ### initialize Method API Documentation Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.BotProfileModel Initializes the model. This method is inherited from the Model class. ```APIDOC initialize(): void Parameters: None Returns: void Inherited from: Model.initialize ``` -------------------------------- ### JavaScript Example: Get Common Groups for a Contact Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.contact.getCommonGroups Illustrative JavaScript code snippet demonstrating how to use the `WPP.contact.getCommonGroups` function to retrieve the IDs of all groups shared with a specified contact. ```JavaScript const groups_ids = await WPP.contact.getCommonGroups('[number]@c.us'); ``` -------------------------------- ### API: initializeAltDeviceLinking Function Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.whatsapp.functions.initializeAltDeviceLinking Provides the API signature and return type for the `initializeAltDeviceLinking` function, which returns a Promise that resolves to void. ```APIDOC initializeAltDeviceLinking(): Promise Returns: Promise ``` -------------------------------- ### startDownloading Function API Reference Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.whatsapp.Browser.startDownloading Provides the API signature and return type for the `startDownloading` function, which is part of the `WAJS.whatsapp.Browser` module within the wppconnect library. ```APIDOC Function: startDownloading Signature: startDownloading(): void Returns: void Source: node_modules/@wppconnect/wa-js/dist/whatsapp/misc/Browser.d.ts:30 ``` -------------------------------- ### slice Method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.StickerSearchCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): StickerModel[] Description: Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. Parameters: start (Optional): number - The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end (Optional): number - The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: StickerModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### API Method: slice Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): ProductModel[] Parameters: start (Optional): number - The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end (Optional): number - The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: ProductModel[] Inherited From: Collection.slice Defined In: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### slice Method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.AggReactionsCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): AggReactionsModel[] Parameters: start: Optional number The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: Optional number The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: AggReactionsModel[] Inherited from Collection.slice Defined in node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### MediaPrep Namespace API Reference Source: https://wppconnect.io/wppconnect/modules.html/modules/WAJS.whatsapp.MediaPrep Detailed API documentation for the `MediaPrep` namespace, outlining its core components: the `MediaPrep` class and the `prepRawMedia` function. This namespace provides utilities for preparing media within the WPPConnect library. ```APIDOC Namespace: MediaPrep Classes: - MediaPrep Path: WAJS.whatsapp.MediaPrep.MediaPrep Functions: - prepRawMedia Path: WAJS.whatsapp.MediaPrep.prepRawMedia ``` -------------------------------- ### Model Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.LabelModel Initializes the model. This method takes no arguments and returns void. ```APIDOC Method: initialize Signature: initialize(): void Returns: void Inherited From: Model Defined In: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### slice Method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.StickerCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): StickerModel[] Parameters: start: number (Optional) The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: number (Optional) The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: StickerModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### Initialize Model (initialize) API Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.OrderModel Initializes the model. This method takes no parameters and returns void. ```APIDOC initialize(): void Returns: void Inherited from: WAJS.whatsapp.Model ``` -------------------------------- ### API Method: slice Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.RecentStickerCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): StickerModel[] Parameters: start: Optional number The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: Optional number The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: StickerModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### API: slice method for ProductMessageListModel Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductMessageListCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): ProductMessageListModel[] Parameters: start: Optional number The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: Optional number The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: ProductMessageListModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### Initialize and Use FileTokenStore with wppconnect Source: https://wppconnect.io/wppconnect/modules.html/classes/tokenStore.FileTokenStore Demonstrates how to create an instance of `FileTokenStore` and integrate it with `wppconnect.create` to manage session tokens using a file-based storage mechanism. Shows optional configuration parameters for customization. ```typescript import * as wppconnect from '@wppconnect-team/wppconnect'; const myTokenStore = new wppconnect.tokenStore.FileTokenStore({ // decodeFunction: JSON.parse, // encodeFunction: JSON.stringify, // encoding: 'utf8', // fileExtension: '.my.ext', // path: './a_custom_path', }); wppconnect.create({ session: 'mySession', tokenStore: myTokenStore, }); wppconnect.create({ session: 'otherSession', tokenStore: myTokenStore, }); ``` -------------------------------- ### Get Index of Message Info Model (indexOf) Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.MsgInfoCollection Searches for the first occurrence of a MsgInfoModel within the collection and returns its index, or -1 if not found. The search can be initiated from a specified starting index. This method is inherited from BaseCollection. ```APIDOC indexOf(searchElement: MsgInfoModel, fromIndex?: number): number Returns the index of the first occurrence of a value in an array, or -1 if it is not present. Parameters: searchElement: MsgInfoModel The value to locate in the array. fromIndex: number (Optional) The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. Returns: number Inherited from BaseCollection.indexOf Defined in node_modules/typescript/lib/lib.es5.d.ts:1418 ``` -------------------------------- ### NoteModel Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.NoteModel Initializes the model. This method is inherited from `Model`. ```APIDOC initialize(): void Returns: void Inherited from: Model.initialize Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### API Method: slice Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ButtonCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): ReplyButtonModel[] start: Optional number. The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: Optional number. The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: ReplyButtonModel[] ``` -------------------------------- ### ImageUtils Namespace API Overview Source: https://wppconnect.io/wppconnect/modules.html/modules/WAJS.whatsapp.ImageUtils Provides a high-level overview of the ImageUtils namespace, listing its functions and associated WhatsApp version compatibility. ```APIDOC Namespace: ImageUtils Compatibility: Whatsapp 51428 Whatsapp 36638 >= 2.2204.13 Whatsapp 551428 >= 2.2222.8 Functions: - rotateAndResize ``` -------------------------------- ### API Method: slice Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.BusinessCategoriesResultCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): BusinessCategoriesResultModel[] Parameters: Optional start: number The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. Optional end: number The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: BusinessCategoriesResultModel[] ``` -------------------------------- ### wppconnect-modules API Overview Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.AttachMediaModel An overview of the available constructors, properties, and methods within the wppconnect-modules API, providing a quick reference to the module's capabilities. ```APIDOC API Structure: Constructors: - constructor Properties: - attributes - caption - collection - documentPageCount - editedFile - exception - file - fileExt - filename - fileOrigin - filesize - fullPreview - fullPreviewSize - gifAttribution - id - isGif - isState - isVcardOverMmsDocument - mediaEditorData - mediaPrep - mimetype - mirrorMask - originalMimetype - parent - preview - previewable - processPromise - proxyName - stale - state - type - uiProcessed - allowedIds - idClass - Proxy Methods: - addChild - bind - canRedoMediaEditorData - canUndoMediaEditorData - clear - decObservers - delete - emit - get - getDefault - getFileType - hasObservers - hasUnfiredChanges - incObservers - initialize - isListening - isViewableOnce - listenTo - listenToAndRun - listenToOnce - off - on - once - processAttachment - redoMediaEditorData - removeAllListeners - removeListener - reset - sendToChat - serialize - set - stopListening - toJSON - trigger - unbind - undoMediaEditorData - unset - updateCaption - updateEditedFile - updateFullPreview - updateMediaEditorData - updatePreview - isIdType ``` -------------------------------- ### APIDOC: slice method for Collections Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.TemplateButtonCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): TemplateButtonModel[] Parameters: start: number (Optional) The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: number (Optional) The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: TemplateButtonModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### slice method for ProductImageModel Array Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductImageCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): ProductImageModel[] Parameters: start (Optional, type: number): The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end (Optional, type: number): The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: ProductImageModel[] Inherited from: Collection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### Initialize Model (initialize) Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ProductModel Initializes the model. This method is inherited from the Model class. ```APIDOC initialize(): void Returns: void Inherited from: Model Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ``` -------------------------------- ### API Method: slice Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.EmojiVariantCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): EmojiVariantModel[] Parameters: start: number (Optional) - The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: number (Optional) - The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: EmojiVariantModel[] ``` -------------------------------- ### APIDOC: initialize Method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.ServerPropsModel Initializes the model. Inherited from Model.initialize. ```APIDOC initialize(): void Returns: void Inherited from Model.initialize ``` -------------------------------- ### slice Method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.BaseCollection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC Method Signature: slice(start?: number, end?: number): [C](#constructorbasecollectionc)[] Description: Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. Inherited From: Collection.slice Defined In: node_modules/typescript/lib/lib.es5.d.ts:1381 Parameters: start: number (Optional) - The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: number (Optional) - The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: [C](#constructorbasecollectionc)[] ``` -------------------------------- ### API Documentation for startHandlingRequests Function Source: https://wppconnect.io/wppconnect/modules.html/functions/WAJS.whatsapp.websocket.startHandlingRequests Details the `startHandlingRequests` function, including its full signature, the type of value it returns, and the specific file where it is defined. This function is asynchronous and returns a Promise. ```APIDOC Function: startHandlingRequests Signature: startHandlingRequests(): Promise Returns: Promise Defined In: node_modules/@wppconnect/wa-js/dist/whatsapp/websocket/stopComms.d.ts:20 ``` -------------------------------- ### API: slice method Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.StatusV3Collection Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. ```APIDOC slice(start?: number, end?: number): StatusV3Model[] Parameters: start: number (Optional) - The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. end: number (Optional) - The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. Returns: StatusV3Model[] Inherited from: BaseCollection.slice Defined in: node_modules/typescript/lib/lib.es5.d.ts:1381 ``` -------------------------------- ### API Method: initialize Source: https://wppconnect.io/wppconnect/modules.html/classes/WAJS.whatsapp.StickerPackModel Initializes the model instance. This method is inherited from the Model class and returns void, typically used for setting up the model's initial state. ```APIDOC initialize(): void Returns: void Inherited from: Model.initialize Defined in: node_modules/@wppconnect/wa-js/dist/whatsapp/models/Model.d.ts:47 ```