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

@tehlink-id/ngonek

v1.0.2

Published

Node.js SDK for Ngonek WhatsApp Gateway Platform

Readme

@tehlink-id/ngonek

SDK Resmi Node.js untuk platform Ngonek WhatsApp Gateway. Library ini mempermudah developer dalam mengintegrasikan pengiriman pesan WhatsApp (tunggal maupun massal/batch) dan verifikasi webhook signature di aplikasi Node.js.

Fitur Utama

  • Pengiriman Pesan WhatsApp Tunggal (Teks kustom maupun menggunakan Template Database).
  • Pengiriman Pesan Massal (Batch) dengan sistem antrean teratur untuk mencegah pemblokiran nomor.
  • Verifikasi Webhook Signature terintegrasi menggunakan HMAC SHA-256 (timing-safe comparison).
  • Zero Dependencies di sisi runtime (hanya menggunakan modul bawaan Node.js).
  • Dukungan TypeScript penuh dengan autocompletion tipe data yang lengkap.

Instalasi

Instal paket menggunakan package manager pilihan Anda:

npm install @tehlink-id/ngonek

atau menggunakan Yarn / Pnpm:

yarn add @tehlink-id/ngonek
# atau
pnpm add @tehlink-id/ngonek

Penggunaan

1. Inisialisasi Client

Dapatkan Token API Anda terlebih dahulu dari Dashboard Ngonek pada menu API Developer.

import { NgonekClient } from '@tehlink-id/ngonek'

const client = new NgonekClient({
  apiKey: 'YOUR_API_TOKEN'
})

2. Kirim Pesan Tunggal

A. Pesan Kustom Biasa

client.sendMessage({
  deviceId: 'DEVICE_DATABASE_ID',
  receiver: '628123456789',
  message: 'Halo dari SDK Node.js Ngonek!'
})
.then(response => {
  console.log('Pesan Terkirim:', response)
})
.catch(error => {
  console.error('Gagal Mengirim:', error)
})

B. Menggunakan Template Database

client.sendMessage({
  deviceId: 'DEVICE_DATABASE_ID',
  receiver: '628123456789',
  templateId: 'TEMPLATE_DATABASE_ID',
  variables: {
    nama: 'Budi',
    tagihan: 'Rp 150.000'
  }
})
.then(response => {
  console.log('Pesan Terkirim:', response)
})
.catch(error => {
  console.error('Gagal Mengirim:', error)
})

3. Kirim Pesan Massal (Batch)

Sangat disarankan menggunakan API Batch untuk mengirim pesan dalam jumlah banyak secara bersamaan guna menghindari pemblokiran nomor WhatsApp oleh sistem WhatsApp.

A. Mode Pesan Kustom Per Penerima

client.sendBatchMessage({
  deviceId: 'DEVICE_DATABASE_ID',
  recipients: [
    {
      phone: '628123456789',
      message: 'Halo Budi, akun Anda telah aktif!'
    },
    {
      phone: '628987654321',
      message: 'Halo Andi, silakan konfirmasi kehadiran Anda.'
    }
  ],
  delay: 5 // Jeda pengiriman antar pesan (menit)
})
.then(response => {
  console.log('Batch Sukses:', response)
})
.catch(error => {
  console.error('Batch Gagal:', error)
})

B. Mode Template Database

client.sendBatchMessage({
  deviceId: 'DEVICE_DATABASE_ID',
  templateId: 'TEMPLATE_DATABASE_ID',
  recipients: [
    {
      phone: '628123456789',
      variables: {
        nama: 'Budi',
        tagihan: 'Rp 150.000'
      }
    },
    {
      phone: '628987654321',
      variables: {
        nama: 'Andi',
        tagihan: 'Rp 75.000'
      }
    }
  ],
  delay: 5
})
.then(response => {
  console.log('Batch Sukses:', response)
})
.catch(error => {
  console.error('Batch Gagal:', error)
})

C. Mode Custom Template String (Dinamis Seketika)

client.sendBatchMessage({
  deviceId: 'DEVICE_DATABASE_ID',
  template: 'Halo {nama}, tagihan Anda sebesar {jumlah} jatuh tempo pada {tanggal}.',
  recipients: [
    {
      phone: '628123456789',
      variables: {
        nama: 'Budi',
        jumlah: 'Rp 150.000',
        tanggal: '15 Juni'
      }
    }
  ],
  delay: 2
})
.then(response => {
  console.log('Batch Sukses:', response)
})
.catch(error => {
  console.error('Batch Gagal:', error)
})

4. Verifikasi Webhook Signature

Jika Anda menggunakan fitur Webhook dari Ngonek untuk menerima laporan status pengiriman pesan, Anda wajib memverifikasi signature yang dikirimkan pada header X-TehLink-Signature guna memastikan request tersebut asli dikirim dari server Ngonek.

import { NgonekUtils } from '@tehlink-id/ngonek'

// Express.js / Fastify Route Handler
app.post('/webhook', (req, res) => {
  const signature = req.headers['x-tehlink-signature']
  const rawBody = JSON.stringify(req.body) // Gunakan raw body string
  const webhookSecret = 'YOUR_WEBHOOK_SECRET_KEY' // Dari dashboard Ngonek

  const isValid = NgonekUtils.verifyWebhookSignature(rawBody, signature, webhookSecret)

  if (!isValid) {
    return res.status(401).send('Signature tidak valid')
  }

  // Lanjutkan memproses payload webhook
  console.log('Webhook payload:', req.body)
  res.status(200).send('OK')
})

Penanganan Error (Error Handling)

SDK akan melempar error dengan format terstruktur jika terjadi kegagalan validasi atau masalah koneksi.

client.sendMessage({
  deviceId: 'INVALID_ID',
  receiver: '628123456789',
  message: 'Halo!'
})
.catch(error => {
  // error.message berisi deskripsi masalah dari server Ngonek
  console.error('Error Code:', error.statusCode) // contoh: 404
  console.error('Detail Error:', error.message) // contoh: Perangkat tidak ditemukan
})

Lisensi

MIT