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 πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

bhoriwal-sdk

v2.0.28

Published

πŸš€ Powerful WhatsApp Cloud API SDK for Node.js – Send messages, templates, media, flows & more with ease

Readme

πŸš€ Bhoriwal WhatsApp SDK

A simple, powerful, and reusable SDK for the WhatsApp Cloud API.

Built for:

  • Multi-project usage
  • SaaS platforms
  • Backend automation systems

✨ Features

  • βœ… Send Text Messages
  • βœ… Send Media (Image, Video, Document, Audio)
  • βœ… Send Template Messages
  • βœ… Interactive Button Messages
  • βœ… WhatsApp Flows Support
  • βœ… Bulk Messaging
  • βœ… Phone Number Reachability Check
  • βœ… Mark Messages as Read
  • βœ… Block / Unblock Users
  • βœ… Fetch Templates
  • βœ… Analyze Template Structure (πŸ”₯ Smart Feature)
  • βœ… One-time Configuration

πŸ“¦ Installation

npm install bhoriwal-sdk

βš™οΈ Configuration (Recommended)

Configure once and use everywhere:

import Bhoriwal from "bhoriwal-sdk";

Bhoriwal.config({
  token: process.env.WA_ACCESS_TOKEN,
  phoneId: process.env.WA_PHONE_NUMBER_ID,
  wabaId: process.env.WA_BUSINESS_ACCOUNT_ID
});

πŸ” Environment Variables

WA_PHONE_NUMBER_ID=xxxxxxxxxxxx
WA_ACCESS_TOKEN=EAAGxxxxxxxxxxxxxxxx
WA_BUSINESS_ACCOUNT_ID=xxxxxxxxxxxx

πŸ’¬ Send Text Message

await Bhoriwal.sendText({
  to: "919999999999",
  message: "Hello from Bhoriwal πŸš€"
});

πŸ“Œ Works only within 24-hour customer window.


πŸ–ΌοΈ Send Media Message

await Bhoriwal.sendMedia({
  to: "919999999999",
  type: "image", // image | video | document | audio
  link: "https://example.com/image.jpg",
  caption: "Check this out πŸ‘€"
});

🧾 Send Template Message

await Bhoriwal.sendTemplate({
  to: "919999999999",
  name: "order_update",
  components: [
    {
      type: "body",
      parameters: [
        { type: "text", text: "John" },
        { type: "text", text: "ORD123" }
      ]
    }
  ]
});

πŸ“Œ Templates must be approved in Meta.


πŸ” Fetch & Analyze Templates (πŸ”₯ Powerful Feature)

1️⃣ Get All Templates

const templates = await Bhoriwal.getTemplates();

2️⃣ Find Template

const template = templates.find(t => t.name === "order_update");

3️⃣ Analyze Template Structure

const info = Bhoriwal.analyzeTemplate(template);

console.log(info);

βœ… Example Output

{
  name: "order_update",
  bodyParams: [
    { index: 1, type: "text" },
    { index: 2, type: "text" }
  ],
  header: {
    type: "image"
  },
  buttons: [
    { buttonIndex: 0, type: "dynamic_url" }
  ]
}

πŸ’‘ What This Means

  • Body requires 2 text parameters
  • Header requires an image
  • Button needs dynamic value

πŸ‘‰ No more guessing template structure 🎯


πŸ”˜ Send Button Message (Interactive)

await Bhoriwal.sendMessageFlow({
  to: "919999999999",
  message: "Hello πŸ‘‹ Please choose an option:",
  buttons: [
    { id: "order", title: "Order" },
    { id: "contact", title: "Contact" },
    { id: "other", title: "Other" }
  ]
});

πŸ“Œ Button Rules

  • Maximum 3 buttons
  • Title max 20 characters
  • ID max 256 characters

πŸ”„ Send WhatsApp Flow

await Bhoriwal.sendFlow({
  to: "919999999999",
  flowId: "123456",
  flowToken: "abc123",
  flowData: {
    name: "John"
  }
});

πŸ“€ Bulk Messaging

await Bhoriwal.bulkSend(
  [
    { to: "919111111111", message: "Hello 1" },
    { to: "919222222222", message: "Hello 2" }
  ],
  Bhoriwal.sendText
);

☎️ Check Phone Number

await Bhoriwal.checkPhoneNumber({
  to: "919999999999"
});

πŸ“Œ Uses safe verification method (no official API available).


πŸ‘οΈ Mark Message as Read

await Bhoriwal.markAsRead({
  messageId: "wamid.HBg..."
});

🚫 Block / Unblock User

Block

await Bhoriwal.blockUser({
  to: "919999999999"
});

Unblock

await Bhoriwal.unblockUser({
  to: "919999999999"
});

⚠️ Important Notes

  • Template messages are required outside the 24-hour window
  • Some features (Flows, Blocking) require Meta approval
  • Phone check is a workaround, not official API

🧠 Best Practices

  • Use templates for notifications
  • Analyze templates before sending
  • Cache templates for performance
  • Validate inputs before sending
  • Use bulk messaging carefully (rate limits)

πŸ“„ License

MIT


❀️ Support

If you like this project, consider starring ⭐ and sharing it.