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

townkrier-wasender

v1.0.1-alpha.1

Published

WaSender (WhatsApp) driver for Townkrier

Downloads

114

Readme

townkrier-wasender

Wasender WhatsApp adapter for the TownKrier notification system.

Features

  • 📱 WhatsApp Business API integration via Wasender
  • 🌍 Support for international messaging
  • 🔄 Automatic retry and error handling
  • 📝 Rich text message support
  • 🔍 Message delivery tracking
  • 🛡️ Type-safe configuration

Installation

npm install townkrier-wasender townkrier-core
# or
pnpm add townkrier-wasender townkrier-core

Quick Start

import { NotificationManager } from 'townkrier-core';
import { createWasenderAdapter, WasenderConfig } from 'townkrier-wasender';

// Configure Wasender adapter
const wasenderConfig: WasenderConfig = {
  apiKey: process.env.WASENDER_API_KEY,
  baseUrl: 'https://wasenderapi.com/api', // Optional, defaults to this URL
  senderId: 'YourSenderId', // Optional sender ID
};

// Create the adapter
const wasenderAdapter = createWasenderAdapter(wasenderConfig);

// Use with NotificationManager
const manager = new NotificationManager();

// Send a WhatsApp message
const result = await wasenderAdapter.send({
  to: { phone: '+1234567890' },
  text: 'Hello from TownKrier via Wasender!',
});

console.log('Message sent:', result.messageId);

Configuration

WasenderConfig

interface WasenderConfig extends NotificationChannelConfig {
  apiKey: string; // Required: Your Wasender API key
  baseUrl?: string; // Optional: API base URL (default: 'https://wasenderapi.com/api')
  senderId?: string; // Optional: Sender ID for your messages
}

Environment Variables

WASENDER_API_KEY=your_api_key_here

Usage with NotificationManager

import { NotificationManager, NotificationChannel } from 'townkrier-core';
import { createWasenderAdapter } from 'townkrier-wasender';

const manager = new NotificationManager({
  defaultChannel: 'whatsapp-wasender',
  channels: [
    {
      name: 'whatsapp-wasender',
      enabled: true,
      config: {
        apiKey: process.env.WASENDER_API_KEY,
        baseUrl: 'https://wasenderapi.com/api',
      },
    },
  ],
});

// Register the factory
manager.registerFactory('whatsapp-wasender', createWasenderAdapter);

// Send notification
await manager.send({
  channel: 'whatsapp-wasender',
  to: { phone: '+1234567890' },
  text: 'Welcome to our service!',
});

Error Handling

The adapter handles various error scenarios:

  • Authentication errors: Invalid API key
  • Rate limiting: Automatic retry with backoff
  • Network issues: Timeout and connection errors
  • Invalid recipients: Phone number validation
try {
  const result = await wasenderAdapter.send({
    to: { phone: '+1234567890' },
    text: 'Test message',
  });

  if (result.status === 'FAILED') {
    console.error('Message failed to send');
  }
} catch (error) {
  console.error('Adapter error:', error);
}

API Reference

createWasenderAdapter(config)

Factory function to create a Wasender adapter instance.

Parameters:

  • config (WasenderConfig): Configuration object

Returns: WasenderAdapter instance

WasenderAdapter

send(request)

Send a WhatsApp message.

Parameters:

  • request (WhatsAppRequest): Message request object

Returns: Promise<WhatsAppResponse>

Rate Limits

Be aware of Wasender's rate limits:

  • Messages per minute: Varies by plan
  • Messages per hour: Varies by plan
  • Messages per day: Varies by plan

The adapter does not implement rate limiting - consider using TownKrier's queue system for production use.

Support

For issues specific to the Wasender adapter:

  1. Check your API key and configuration
  2. Verify phone numbers are in international format
  3. Review Wasender API documentation
  4. Check TownKrier logs for detailed error messages

License

MIT