Giter VIP home page Giter VIP logo

whatsapp-cloud-api-wrapper's Introduction

Whatsapp Cloud API Wrapper

License: GPL-3.0 license npm versionOpen Source Love svg2

This library is a Node.js wrapper for the Whatsapp Cloud API. It simplifies the process of interacting with the API by handling request and response formatting, authentication, and providing easy-to-use methods for common API operations.

(Give star if you like it :)

Features

  • Easy to use and configure
  • Supports sending and replying to text, image, audio, and document messages
  • Supports setting up webhook servers for receiving events
  • Built-in support for ngrok
  • Automatically handles authentication and access tokens
  • Automatically identify the webhook type data like Notification or Message

Installation

You can install the package using npm or Yarn:

npm install wacloudapi

or

yarn add wacloudapi

Usage

First, import the required classes from the package:

const { Message, WAParser, WebhookServer } = require('wacloudapi);

Sending Messages

Create a new Message instance with your API credentials:

const message = new Message(apiVersion, phoneNumberId, accessToken);

You can now use the various methods provided by the Message class to send messages:

message.sendTextMessage(recipientPhoneNumber, messageContent);

Webhook Server

Create a new WebhookServer instance and specify the desired port and whether to use ngrok:

const webhookServer = new WebhookServer(port, useNgrok, ngrokAuthToken);

Add a listener for incoming messages:

webhookServer.on('message', (message) => {
  console.log('Received message:', message);
});

Add a route for webhook verification:

webhookServer.Verification(callbackUrl, verificationToken);

Start the webhook server:

webhookServer.start();

Webhook Parser

The WAParser class is used to parse incoming webhook data from the WhatsApp Business API.

parseMessage()

Returns the parsed message object depending on the type of message contained in the received webhook data.

const parse = new WAParser(WebhookData);
  // parse message
const parsedMessage = parse.parseMessage();

Notification Parser

The NotificationParser class is used to parse incoming webhook data from the WhatsApp Business API.

NotificationParser()

Returns the parsed message object depending on the type of message contained in the received webhook data.

const parse = new NotificationParser(WebhookData);
  // parse message
const parsedMessage = parse.parseNotification();

Documentation

For detailed information on available methods and how to use them, please refer to the documentation.

Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

  1. Fork the repository
  2. Create a new branch with your changes
  3. Commit your changes and create a pull request

We appreciate any help and feedback!

License

Contact

Email : [email protected]

This project is licensed under the MIT License. See the LICENSE file for more information.

whatsapp-cloud-api-wrapper's People

Contributors

fdciabdul avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

whatsapp-cloud-api-wrapper's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

npm
package.json
  • axios ^1.3.5
  • chalk ^2.4.2
  • cli-cursor ^3.0.0
  • dotenv ^16.0.3
  • express ^4.18.2
  • ngrok ^4.3.3
  • strip-ansi ^5.2.0
  • jsdoc ^4.0.2

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.