npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

chatbot-whatsapp-backend-package

v1.0.0

Published

This is a package for the econsulate chatbot backend

Readme

Econ Chatbot Whatsapp Backend Package

This npm package offers a robust solution for integrating WhatsApp with chatbot systems. It handles webhook verification, processes incoming messages, manages conversation sessions, and stores data in a database. With flexible customization options, it ensures seamless communication between WhatsApp and chatbots.

Table of Contents

  1. Features
  2. Installation
  3. Usage
  4. For Contributors
  5. License

Features

  • Webhook Verification

    Verifies WhatsApp webhook requests to establish secure communication with the WhatsApp API.

  • Message Processing

    Processes incoming WhatsApp messages and prepares them for handling by the chatbot.

  • Conversation Management

    Manages conversation sessions, including creation, tracking, and continuity of conversations.

  • Data Persistence

    Saves conversation and message metadata into a database, ensuring conversation history is stored

  • Message Conversion

    Converts bot-generated messages into a format suitable for WhatsApp before sending.

  • WhatsApp Message Sending

    Sends processed bot responses back to WhatsApp users through the WhatsApp API.

Installation

  1. Download Github repository (URL)
  2. Install Modulesnpm install .
  3. Compile the Node Modulenpm run build.
  4. Link build files with the global NPM packagesnpm link.
  5. Insert package into another repositorynpm link chatbot-whatsapp-backend-package.

Usage

Importing components

import { WhatsAppPackageMiddlewareAuth, WhatsappPackageBackendController } from 'chatbot-whatsapp-backend-package';

Creating Route file

  • Create a route file to define the endpoints for WhatsApp webhook verification and message handling. By setting up these routes, you allow the application to listen for incoming webhook events from WhatsApp and process them accordingly.
class WhatsAppMessageRoute implements IRoutes {
  public path = `/${ROUTES.v1}webhook`;
  public router = Router();
  private whatsAppMessageController = new WhatsAppMessageController();

  constructor() {
    this.initializeRoutes();
  }

  private initializeRoutes() {
    this.router.get(
      `${this.path}`,
      this.whatsAppMessageController.verifyWebhook
    );
    this.router.post(
      `${this.path}`,
      whatsappAuthentication,
      this.whatsAppMessageController.whatsappCallbackHandler
    );
  }
}

export default WhatsAppMessageRoute;

Creating Controller file

  • Create a controller file to handle WhatsApp webhook verification and message processing. And need to import essential components from the npm package, such as WhatsappPackageBackendController, to manage these tasks efficiently.
import { WhatsappPackageBackendController } from "chatbot-whatsapp-backend-package";

class WhatsAppMessageController {
  private messageService: MessageService = new MessageService();
  private messageController: MessageController = new MessageController();
  private dbInstance: DatabaseConnection = new DatabaseConnection();

  // handling the WhatsApp webhook verification and callback events
  private whatsappPackageBackendController =
    new WhatsappPackageBackendController(
      logger,
      handleError,
      HttpException,
      this.dbInstance,
      this.messageService,
      this.messageController,
      MessengerSchema,
      CustomerSchema,
      WhatsappUserConversationSchema
    );

  // Verify the webhook
  public verifyWebhook = async (req: Request, res: Response) => {
    await this.whatsappPackageBackendController.verifyWebhook(req, res);
  };

  // Creates a new text message and sends it
  public whatsappCallbackHandler = async (req: Request, res: Response) => {
    await this.whatsappPackageBackendController.whatsappCallbackHandler(
      req,
      res
    );
  };
}

export default WhatsAppMessageController;

Creating Athentication middleware

  • Create an authentication middleware to secure the WhatsApp webhook requests. And need to import WhatsAppPackageMiddlewareAuth from npm package. This middleware ensures that only authorized requests are processed by verifying the incoming webhook calls against the WhatsApp API.
import { WhatsAppPackageMiddlewareAuth } from "chatbot-whatsapp-backend-package";

const cache = new NodeCache();

// Middleware to authenticate WhatsApp webhook requests
export const whatsappAuthentication = async (
  req: Request,
  res: Response,
  next: NextFunction
) => {
  const dbInstance = new DatabaseConnection();
  await WhatsAppPackageMiddlewareAuth(
    req,
    res,
    next,
    dbInstance,
    ClientModel,
    MessengerSettingSchema,
    cache,
    handleError
  );
};

For Contributors

For more details on development practices, refer to Developer Guide.

License

TBD

Subscription Plan

TBD