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

@onexnpm/wa-sender

v1.0.4

Published

A simple WhatsApp sender with predefined templates.

Downloads

11

Readme

📦 @onexnpm/wa-sender

A simple and elegant WhatsApp message sender built on top of Baileys.
Includes predefined message templates and easy-to-use methods for sending messages programmatically.


🚀 Features

✅ Easy WhatsApp connection via QR code
✅ Predefined templates for common message types (welcome, verification, shipping, etc.)
✅ Promise-based API for clean async usage
✅ Built with TypeScript-friendly JSDoc types
✅ Simple logging using pino
✅ Modular and extensible structure


📦 Installation

npm install @onexnpm/wa-sender
# or
yarn add @onexnpm/wa-sender

🧠 Usage Example

Create a file example.js:

import { WhatsappClient } from '@onexnpm/wa-sender';

const RECIPIENT_NUMBER = "94771234567"; // Replace with your WhatsApp number

const main = async () => {
  console.log('Initializing WhatsApp client...');
  const client = new WhatsappClient();

  await client.initialize();

  console.log('Client connected! Sending messages...');

  await client.sendTemplateMessage(RECIPIENT_NUMBER, 'welcome', {
    name: 'John Doe',
    company: 'OneX Universe',
  });

  await client.sendTemplateMessage(RECIPIENT_NUMBER, 'verificationCode', {
    code: '812399',
  });

  console.log('All messages sent. Disconnecting...');
  await client.disconnect();
};

main();

Run:

node example.js

The first time you run it, a QR code will be displayed in the terminal.
Scan it with your WhatsApp to authenticate.


| Template Name | Description | Example Fields | | ----------------------------- | ----------------------------------------------------- | ------------------------------------------------- | | welcome | Sends a welcome message | { name, company } | | verificationCode | Sends a verification code | { code } | | resetCode | Sends a password reset code | { code } | | passwordChangedNotice | Alerts user that their password has been changed | { username } | | orderStatus | Updates on order status | { orderId, status } | | shippingUpdate | Sends shipping update with tracking info | { orderId, carrier, trackingNumber } | | invoiceGenerated | Notifies user of a newly generated invoice | { invoiceId, amount, dueDate } | | subscriptionRenewalReminder | Alerts about subscription renewal | { planName, renewalDate, amount } | | paymentReceived | Notifies user that payment has been received | { amount, invoiceId } | | paymentFailed | Alerts user about a failed payment | { amount } | | appointmentReminder | Reminds user of an appointment | { serviceName, dateTime, location } | | eventInvitation | Sends event invitation | { eventName, venue, date, time } | | meetingReminder | Reminds user of a scheduled meeting | { withPerson, dateTime, meetingLink } | | accountDeactivated | Alerts user that their account has been deactivated | { username } | | accountReactivated | Notifies user that their account has been reactivated | { username } | | otpLogin | Sends OTP for login | { otp } | | feedbackRequest | Requests feedback from user | { name, company } | | thankYouPurchase | Sends a thank-you message after purchase | { name, company } | | promotionalOffer | Sends promotional or discount offers | { offerTitle, promoCode, discount, expiryDate } | | seasonalGreeting | Sends festive or seasonal greetings | { greetingTitle, company, message } | | systemAlert | Internal system or admin alert | { alertMessage, timestamp } | | newUserSignup | Notifies admin of a new user signup | { name, email } | | adminNotification | Generic admin alert | { message } |


🧰 API Reference

class WhatsappClient

new WhatsappClient(options?)

| Option | Type | Default | Description | |--------|------|----------|-------------| | authPath | string | 'auth_info_baileys' | Path to save session data | | logger | pino.Logger | Built-in logger | Custom logger instance |

initialize(): Promise<boolean>

Initializes the WhatsApp connection. Prompts QR code on first run.

sendTemplateMessage(to, templateName, data): Promise<void>

Sends a predefined template message.

sendRawMessage(to, messageContent): Promise<void>

Send a raw WhatsApp message (text, image, etc.).

disconnect(): Promise<void>

Disconnects from WhatsApp gracefully.

logout(): Promise<void>

Logs out and invalidates saved credentials.


🧱 Project Structure

📁 wa-sender/
├── index.js                # Main WhatsApp client class
├── src/
│   └── templates.js        # Message templates
├── example.js              # Usage demo
├── package.json
├── .gitignore
└── README.md

🛠️ Development

Clone the repository:

git clone https://github.com/Seneth-Jayashan/wa-sender.git
cd wa-sender
npm install
npm start

To test the package locally before publishing:

npm link

Then in another project:

npm link @onexnpm/wa-sender

🔒 Notes

  • QR authentication data is stored in the auth_info_baileys/ folder.
  • To re-login or change account, delete that folder and rerun the script.
  • Only one active session per account is supported per device.

📄 License

ISC © S JAY


🌐 Links


Proudly Developed by OneX Universe - S JAY