### Install Project Dependencies Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Installs the necessary dependencies for the WPPConnect Server project using either Yarn or npm package managers. ```Shell yarn install //or npm install ``` -------------------------------- ### Get WPPConnect QR Code Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Retrieves the QR code for a WhatsApp session that is currently starting. If the start-session method is called again while the session is initializing, it returns the base64 encoded QR code. ```sh #Get QrCode # /api/:session/start-session # when the session is starting if the method is called again it will return the base64 qrCode curl -X POST --location "http://localhost:21465/api/mySession/start-session" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $2b$10$JcHd97xHN6ErBuiLd7Yu4.r6McvOvEZZDQTQwev2MRK_zQObUZZ9C" ``` -------------------------------- ### Start WPPConnect Session Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Initiates a new WhatsApp session using the WPPConnect Server API. This requires a POST request to the /api/:session/start-session endpoint with appropriate authentication headers. ```sh #Starting Session # /api/:session/start-session curl -X POST --location "http://localhost:21465/api/mySession/start-session" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $2b$10$JcHd97xHN6ErBuiLd7Yu4.r6McvOvEZZDQTQwev2MRK_zQObUZZ9C" ``` -------------------------------- ### Install Puppeteer Dependencies Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Installs essential system dependencies required for Puppeteer, a headless Chrome Node.js API, which is likely used by WPPConnect Server for browser automation. ```Shell sudo apt-get install -y libxshmfence-dev libgbm-dev wget unzip fontconfig locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils libvips-dev ``` -------------------------------- ### Install Google Chrome Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Downloads and installs the latest stable version of Google Chrome on Debian-based systems, a prerequisite for running WPPConnect Server which likely utilizes Chrome for its operations. ```Shell wget -c https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt-get update sudo apt-get install libappindicator1 sudo dpkg -i google-chrome-stable_current_amd64.deb ``` -------------------------------- ### Troubleshoot Sharp Runtime Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Provides commands to resolve 'Sharp Runtime' errors by installing or reinstalling the 'sharp' library, which is a high performance Node.js image processing module. ```Shell yarn add sharp npm install --include=optional sharp //or yarn add sharp --ignore-engines ``` -------------------------------- ### Run WPPConnect Server Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Starts the WPPConnect Server in development mode using the 'dev' script defined in the project's package.json, typically managed by Yarn. ```Shell yarn dev ``` -------------------------------- ### Build WPPConnect Server Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Compiles and builds the WPPConnect Server project for production deployment using the 'build' script, commonly executed with Yarn. ```Shell yarn build ``` -------------------------------- ### WppConnect Server Default Configuration Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Provides the default configuration object for the WppConnect server, outlining various settings such as secret key, host, port, webhook details, database connections, and AWS S3 integration. ```javascript { /* secret key to generate access token */ secretKey: 'THISISMYSECURETOKEN', host: 'http://localhost', port: '21465', // Device name for show on whatsapp device deviceName: 'WppConnect', poweredBy: 'WPPConnect-Server', // starts all sessions when starting the server. startAllSession: true, tokenStoreType: 'file', // sets the maximum global listeners. 0 = infinity. maxListeners: 15, // create userDataDir for each puppeteer instance for working with Multi Device customUserDataDir: './userDataDir/', webhook: { // set default webhook url: null, // automatically downloads files to upload to the webhook autoDownload: true, // enable upload to s3 uploadS3: false, // set default bucket name on aws s3 awsBucketName: null, //marks messages as read when the webhook returns ok readMessage: true, //sends all unread messages to the webhook when the server starts allUnreadOnStart: false, // send all events of message status (read, sent, etc) listenAcks: true, // send all events of contacts online or offline for webook and socket onPresenceChanged: true, // send all events of groups participants changed for webook and socket onParticipantsChanged: true, // send all events of reacted messages for webook and socket onReactionMessage: true, // send all events of poll messages for webook and socket onPollResponse: true, // send all events of revoked messages for webook and socket onRevokedMessage: true, // send all events of labels for webook and socket onLabelUpdated: true, // 'event', 'from' or 'type' to ignore and not send to webhook ignore: [], }, websocket: { // Just leave one active, here or on webhook.autoDownload autoDownload: false, // Just leave one active, here or on webhook.uploadS3, to avoid duplication in S3 uploadS3: false, }, // send data to chatwoot chatwoot: { sendQrCode: true, sendStatus: true, }, //functionality that archives conversations, runs when the server starts archive: { enable: false, //maximum interval between filings. waitTime: 10, daysToArchive: 45, }, log: { level: 'silly', // Before open a issue, change level to silly and retry an action logger: ['console', 'file'], }, // create options for using on wppconnect-lib createOptions: { browserArgs: [ '--disable-web-security', '--no-sandbox', '--disable-web-security', '--aggressive-cache-discard', '--disable-cache', '--disable-application-cache', '--disable-offline-load-stale-cache', '--disk-cache-size=0', '--disable-background-networking', '--disable-default-apps', '--disable-extensions', '--disable-sync', '--disable-translate', '--hide-scrollbars', '--metrics-recording-only', '--mute-audio', '--no-first-run', '--safebrowsing-disable-auto-update', '--ignore-certificate-errors', '--ignore-ssl-errors', '--ignore-certificate-errors-spki-list', '--disable-features=LeakyPeeker' // Disable the browser's sleep mode when idle, preventing the browser from going into sleep mode, this is useful for WhatsApp not to be in economy mode in the background, avoiding possible crashes ], }, mapper: { enable: false, prefix: 'tagone-', }, // Configurations for connect with database db: { mongodbDatabase: 'tokens', mongodbCollection: '', mongodbUser: '', mongodbPassword: '', mongodbHost: '', mongoIsRemote: true, mongoURLRemote: '', mongodbPort: 27017, redisHost: 'localhost', redisPort: 6379, redisPassword: '', redisDb: 0, redisPrefix: 'docker', }, // Your configurations to upload on AWS aws_s3: { region: 'sa-east-1', access_key_id: '', secret_key: '', // If you already have a bucket created that will be used. Will be stored: you-default-bucket/{session}/{filename} defaultBucketName: '' }, } ``` -------------------------------- ### Generate WppConnect Access Token via cURL Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Demonstrates how to generate an access token for the WppConnect server using a cURL command. It requires the secret key defined in the configuration and specifies the API endpoint for token generation. ```shell curl -X POST --location "http://localhost:21465/api/mySession/THISISMYSECURETOKEN/generate-token" ``` -------------------------------- ### WppConnect Token Generation Response Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Shows the expected JSON response after successfully generating an access token for the WppConnect server. The response includes the status, session name, and the generated token. ```json { "status": "Success", "session": "mySession", "token": "$2b$10$duQ5YYV6fojn5qFiFv.aEuY32_SnHgcmxdfxohnjG4EHJ5_Z6QWhe", "full": "wppconnect:$2b$10$duQ5YYV6fojn5qFiFv.aEuY32_SnHgcmxdfxohnjG4EHJ5_Z6QWhe" } ``` -------------------------------- ### Send Message via WPPConnect Source: https://github.com/wppconnect-team/wppconnect-server/blob/main/README.md Sends a message to a specified phone number using the WPPConnect Server API. The request includes the target phone number and the message content, sent via a POST request to the /api/:session/send-message endpoint. ```sh #Send Message # /api/:session/send-message curl -X POST --location "http://localhost:21465/api/mySession/send-message" \ -H "Content-Type: application/json; charset=utf-8" \ -H "Accept: application/json" \ -H "Authorization: Bearer $2b$10$8aQFQxnWREtBEMZK_iHMe.u7NeoNkjL7s6NYai_83Pb31Ycss6Igm" \ -d "{ \"phone\": \"5511900000000\", \"message\": \"*Abner* Rodrigues\" }" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.