Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A very simple typescript whatsapp gateway via expressjs REST API using whatsapp-web.js

NotificationsYou must be signed in to change notification settings

snowfluke/wagate

Repository files navigation

A very simple typescript whatsapp gateway via expressjs REST API using whatsapp-web.js.

Contribution

Any features request and contribution are welcome! ^_^

Installation & Configuration

Configuration

  1. Make sure you clone this repo first
  2. Copy.env.example and rename it to.env
  3. Change the configuration there
  4. Don't forget to change thelogo.jpg in the root directory

Installation

  1. Node.js v20+ , I've setups to 20 in package.json, you can change it but generally it works in Node.js v12 higher
  2. npm package manager
  3. You can go for docker for an easy setups, or if you deploy it manually you will need to install Google Chrome
  4. On an Ubuntu server, you will need to run this command:
sudo apt-get update&& sudo apt-get install -y \    gconf-service \    libgbm-dev \    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 \    wget
  1. cd into the project directory
  2. runnpm install
  3. runnpm run build
  4. runnpm run start
  5. After that you will need to scan the QR that is printed to the terminal
  6. You're basically done, or if you want to be more robust, you can usepm2 for a better process management

Removing delay

You can commented out this line

awaitthis.helper.delay();
and also this line
awaitthis.helper.delay();

Endpoints

  • [GET] /api/v1/

Response:

{"message":"REST API is working"}
  • [POST][Multipart/form-data] /api/v1/send/
namevalue
number628XXX...
contentyour message

Response:

{"status":"success","code":200,"message":"Message sucessfully sent","data": {"number":"628XXX...","content":"Hi, mom!","type":"text"  }}
  • [POST][Multipart/form-data] /api/v1/send/media
namevalue
number628XXX...
contentyour message
filebinary file

Response:

{"status":"success","code":200,"message":"Message sucessfully sent","data": {"number":"628XXX...","content":"this is your media caption","type":"media"  }}

Error response

{"status":"error","code":400,"message":"Bad Image"}

Error code

CodeStatus
200SUCCESS
201CREATED
204NO CONTENT
400BAD REQUEST
401UNAUTHORIZED
403FORBIDDEN
404NOT FOUND
408TIME OUT
429TOO MANY REQUEST
500INTERNAL SERVER ERROR
503SERVICE UNAVAILABLE

Debugging

  • Delete.wwebjs_auth folder
  • Deletenode_modules folder
  • Deletepackage-lock.json file
  • Logout the linked devices on your Whatsapp
  • Removewhatsapp-web.js frompackage.json
  • Runnpm install github:pedroslopez/whatsapp-web.js#webpack-exodus

About

A very simple typescript whatsapp gateway via expressjs REST API using whatsapp-web.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp