Getting Started
Installation
Inside your project directory, run the following:
npm i wh-rapper
Features
Quick Start
To start using the wh-wrapper library, you need to initialize a new WhatsApp client instance.
import Client from "wh-wrapper";
const wh = new Client(phoneID, token);
If you don't have a phoneID
or token
, or if you haven't set up an account with the Cloud API yet, please refer to our Quick Start guide to see all the necessary steps.
If you want to receive incoming messages via the WhatsApp webhook, you can initialize the client with a verifyToken parameter.
import Client from "wh-wrapper";
const wh = new Client(phoneID, token, verifyToken);
If you haven't set up a webhook or are unfamiliar with webhooks, check out our comprehensive Webhook Setup guide for more information.
After initializing the client, you can listen for incoming messages by attaching an event listener to the messages event.
wh.on("messages", async (message) => console.log(message));
You can also listen for message status updates (sent, delivered, read, etc.) by attaching an event listener to the statuses event.
wh.on("statuses", async (status) => console.log(status));
Additionally, you can listen for interactive message callbacks (button presses, section list selections) by attaching an event listener to the callbacks
event.
wh.on("callbacks", async (callback) => console.log(callback));
You can also listen for when a user opens a new chat with the bot by attaching an event listener to the ChatOpened event.
wh.on("ChatOpened", async (chat) => console.log(chat));
TODO
- Added support for Flows
- Editing incoming message types (TypeScript)
- Writing the documentation
License
This project is licensed under the MIT License - see the LICENSE.md file for details