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

@waapcoders/sdk

v1.0.0

Published

Official Node.js SDK for SaaS Chatbot Platform - Easy integration with chatbot APIs

Readme

SaaS Chatbot SDK for Node.js

npm version npm downloads License: MIT

Official Node.js/TypeScript SDK for SaaS Chatbot Platform. Easily integrate chatbot APIs into your Node.js applications.

🚀 Features

  • Full API Coverage - All chatbot endpoints supported
  • TypeScript Support - Full type definitions included
  • Promise-based - Modern async/await support
  • Zero Dependencies - Uses only Node.js built-ins
  • Error Handling - Comprehensive error management
  • Multi-Channel - WhatsApp, Telegram, Web, API channels
  • Ticket System - Support ticket management
  • Company Isolation - Multi-tenant ready
  • ESM & CommonJS - Works in all environments
  • Well Documented - Complete API reference

📦 Installation

npm

npm install @saaschatbot/sdk

yarn

yarn add @saaschatbot/sdk

pnpm

pnpm add @saaschatbot/sdk

🎯 Quick Start

Basic Setup

const ChatbotSDK = require('@saaschatbot/sdk');

const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    sdkURL: 'https://chat.waapcoders.in',
    accessToken: 'YOUR_JWT_TOKEN'
});

// Create a bot
const bot = await sdk.createBot({
    botName: 'My Bot',
    description: 'Customer support bot'
});

console.log('Bot created:', bot);

TypeScript

import ChatbotSDK from '@saaschatbot/sdk';

const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    sdkURL: 'https://chat.waapcoders.in',
    accessToken: 'YOUR_JWT_TOKEN'
});

const bot = await sdk.createBot({
    botName: 'My Bot',
    description: 'Support bot'
});

ES Modules

import ChatbotSDK from '@saaschatbot/sdk';

const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    accessToken: 'YOUR_JWT_TOKEN'
});

📚 API Reference

Bot Management

Create Bot

const bot = await sdk.createBot({
    botName: 'My Chatbot',
    description: 'Customer support chatbot'
});

Get Bot

const bot = await sdk.getBot('bot-id');

List Bots

const bots = await sdk.listBots();

Update Bot

const updated = await sdk.updateBot('bot-id', {
    botName: 'Updated Name',
    description: 'New description'
});

Delete Bot

await sdk.deleteBot('bot-id');

Channel Management

Setup WhatsApp

await sdk.setupWhatsApp('bot-id', {
    phoneNumberId: 'YOUR_PHONE_NUMBER_ID',
    accessToken: 'YOUR_WHATSAPP_TOKEN',
    displayPhoneNumber: '+1234567890'
});

Setup Telegram

await sdk.setupTelegram('bot-id', {
    botToken: 'YOUR_TELEGRAM_BOT_TOKEN',
    webhookUrl: 'https://yourserver.com/telegram/webhook'
});

Get Channels

const channels = await sdk.getChannels('bot-id');

Test WhatsApp

const result = await sdk.testWhatsApp('bot-id', '+1234567890');

Test Telegram

const result = await sdk.testTelegram('bot-id');

Chat & Messaging

Send Message

const response = await sdk.sendMessage({
    botId: 'bot-id',
    botToken: 'bot-token',
    message: 'Hello! How can I help?',
    userId: 'user-id',
    sessionId: 'session-id',
    channel: 'web'
});

Get Conversation

const messages = await sdk.getConversation('session-id');

Ticket Management

Create Ticket

const ticket = await sdk.createTicket({
    botId: 'bot-id',
    subject: 'Customer Issue',
    description: 'User reported an issue',
    priority: 'high',
    channel: 'web',
    customerEmail: '[email protected]',
    customerName: 'John Doe'
});

Get Ticket

const ticket = await sdk.getTicket('ticket-id');

List Tickets

const tickets = await sdk.listTickets('bot-id');

Update Ticket Status

await sdk.updateTicketStatus('ticket-id', 'resolved');

Assign Ticket

await sdk.assignTicket('ticket-id', 'agent-id');

Add Ticket Reply

await sdk.addTicketReply('ticket-id', {
    message: 'Thank you for reporting',
    isCustomerReply: false,
    repliedBy: 'agent-name'
});

Get Ticket Metrics

const metrics = await sdk.getTicketMetrics('bot-id');

Company Management (SuperAdmin only)

Create Company

const company = await sdk.createCompany({
    name: 'Acme Corp',
    email: '[email protected]',
    phone: '+1234567890'
});

List Companies

const companies = await sdk.listCompanies();

Get Company

const company = await sdk.getCompany('company-id');

Update Company

await sdk.updateCompany('company-id', {
    name: 'New Name',
    email: '[email protected]'
});

Settings

Get Settings

const settings = await sdk.getSettings();

Update Settings

await sdk.updateSettings({
    apiKey: 'new-api-key',
    webhookUrl: 'https://yourserver.com/webhook'
});

Get 2FA Status

const twoFaStatus = await sdk.get2FAStatus();

⚙️ Configuration

SDKConfig Interface

interface SDKConfig {
    baseURL: string;           // Required: API base URL
    sdkURL?: string;           // Optional: SDK CDN URL
    accessToken?: string;      // JWT token for authenticated endpoints
    apiKey?: string;           // Alternative: API key authentication
    timeout?: number;          // Request timeout in ms (default: 30000)
    debug?: boolean;           // Enable debug logging (default: false)
}

Environment Variables

# .env file
CHATBOT_API_URL=https://smile.waapcoders.in
CHATBOT_SDK_URL=https://chat.waapcoders.in
CHATBOT_ACCESS_TOKEN=your_jwt_token_here

Usage with Environment Variables

const sdk = new ChatbotSDK({
    baseURL: process.env.CHATBOT_API_URL,
    sdkURL: process.env.CHATBOT_SDK_URL,
    accessToken: process.env.CHATBOT_ACCESS_TOKEN,
    debug: process.env.NODE_ENV === 'development'
});

🔐 Authentication

The SDK supports two authentication methods:

JWT Token (Recommended)

const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
});

API Key

const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    apiKey: 'your-api-key'
});

❌ Error Handling

The SDK provides structured error objects:

try {
    const bot = await sdk.getBot('invalid-id');
} catch (error) {
    console.error('Status:', error.status);      // HTTP status code
    console.error('Message:', error.message);    // Error message
    console.error('Details:', error.data);       // Full response data
}

Common Errors

// 404 - Bot not found
// 401 - Unauthorized (invalid token)
// 400 - Bad request (invalid parameters)
// 500 - Server error

📋 Examples

Complete Bot Setup Example

const ChatbotSDK = require('@saaschatbot/sdk');

async function setupBot() {
    const sdk = new ChatbotSDK({
        baseURL: 'https://smile.waapcoders.in',
        accessToken: process.env.JWT_TOKEN
    });

    try {
        // 1. Create bot
        const bot = await sdk.createBot({
            botName: 'Support Bot',
            description: 'Customer support automation'
        });
        console.log('✓ Bot created:', bot.botId);

        // 2. Setup WhatsApp channel
        await sdk.setupWhatsApp(bot.botId, {
            phoneNumberId: process.env.WHATSAPP_PHONE_ID,
            accessToken: process.env.WHATSAPP_TOKEN,
            displayPhoneNumber: '+1234567890'
        });
        console.log('✓ WhatsApp channel configured');

        // 3. Setup Telegram channel
        await sdk.setupTelegram(bot.botId, {
            botToken: process.env.TELEGRAM_TOKEN,
            webhookUrl: 'https://myserver.com/telegram'
        });
        console.log('✓ Telegram channel configured');

        // 4. Test channels
        await sdk.testWhatsApp(bot.botId, '+1234567890');
        await sdk.testTelegram(bot.botId);
        console.log('✓ Channels tested successfully');

        return bot;
    } catch (error) {
        console.error('Setup failed:', error.message);
        throw error;
    }
}

setupBot().then(bot => {
    console.log('Bot setup complete!', bot);
}).catch(err => {
    process.exit(1);
});

Ticket Management Example

async function handleTickets() {
    const sdk = new ChatbotSDK({
        baseURL: 'https://smile.waapcoders.in',
        accessToken: process.env.JWT_TOKEN
    });

    // Create ticket from chat escalation
    const ticket = await sdk.createTicket({
        botId: 'bot-123',
        subject: 'User reported issue',
        description: 'Customer cannot complete purchase',
        priority: 'high',
        channel: 'web',
        customerEmail: '[email protected]',
        customerName: 'Alice'
    });

    console.log('Ticket created:', ticket.ticketId);

    // List all tickets
    const tickets = await sdk.listTickets('bot-123');
    console.log(`Found ${tickets.length} tickets`);

    // Get metrics
    const metrics = await sdk.getTicketMetrics('bot-123');
    console.log('Metrics:', metrics);
}

🧪 Testing

# Run all tests
npm test

# Run tests in watch mode
npm test:watch

# Run with coverage
npm test -- --coverage

📦 Building

# Build everything (compile, minify, docs)
npm run build

# Build only (compile + minify)
npm run build:dist

# Clean build
npm run clean && npm run build

# Minify only
npm run minify

# Generate docs
npm run build:docs

🚀 Publishing to npm

Setup (First Time)

# Create npm account if you don't have one
npm adduser

# Verify you're logged in
npm whoami

Publishing

# Publish to npm
npm run publish:npm

# Or use npm directly
npm publish --access public

# For beta versions
npm run publish:beta

Versioning

# Update version (major.minor.patch)
npm version patch       # 1.0.0 → 1.0.1
npm version minor       # 1.0.0 → 1.1.0
npm version major       # 1.0.0 → 2.0.0

# This will auto-commit and push to git

🔗 Integration Examples

Express.js Backend

const express = require('express');
const ChatbotSDK = require('@saaschatbot/sdk');

const app = express();
const sdk = new ChatbotSDK({
    baseURL: process.env.CHATBOT_API_URL,
    accessToken: process.env.CHATBOT_TOKEN
});

app.post('/api/bots', async (req, res) => {
    try {
        const bot = await sdk.createBot(req.body);
        res.json(bot);
    } catch (error) {
        res.status(error.status || 500).json({ error: error.message });
    }
});

app.listen(3000);

Next.js API Route

// pages/api/bots.js
import ChatbotSDK from '@saaschatbot/sdk';

const sdk = new ChatbotSDK({
    baseURL: process.env.CHATBOT_API_URL,
    accessToken: process.env.CHATBOT_TOKEN
});

export default async function handler(req, res) {
    if (req.method === 'POST') {
        try {
            const bot = await sdk.createBot(req.body);
            res.status(200).json(bot);
        } catch (error) {
            res.status(error.status || 500).json({ error: error.message });
        }
    }
}

📖 Documentation

🐛 Troubleshooting

Connection Issues

// Enable debug mode to see detailed logs
const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    accessToken: 'your-token',
    debug: true  // Shows all API calls
});

Authentication Errors

// Verify token is valid and not expired
const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    accessToken: process.env.CHATBOT_TOKEN  // Use env variables
});

// Check token claims
console.log('Token:', sdk.accessToken);

Timeout Issues

// Increase timeout for slow connections
const sdk = new ChatbotSDK({
    baseURL: 'https://smile.waapcoders.in',
    accessToken: 'your-token',
    timeout: 60000  // 60 seconds
});

🤝 Contributing

Contributions welcome! Please see CONTRIBUTING.md

📄 License

MIT - See LICENSE

🆘 Support

🔗 Related Resources


Made with ❤️ by SaaS Chatbot Team