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

@hectorbliss/whatsapp-sdk

v0.0.8

Published

TypeScript SDK for WhatsApp Business API with Effect-TS by Fixtergeek

Readme

WhatsApp SDK 📡✨

SDK simple para enviar mensajes por WhatsApp Business API.

Hecho con Effect - Porque los errores no deberían ser sorpresas, sino... ¡efectos! (Sí, somos fans de la programación funcional y no nos da pena admitirlo 😎)

Instalación

npm install @hectorbliss/whatsapp-sdk

Uso básico

import { createWhatsAppService } from "@hectorbliss/whatsapp-sdk";

// Configura tu cliente
const whatsapp = createWhatsAppService({
  phoneNumberId: "TU_PHONE_NUMBER_ID",
  accessToken: "TU_ACCESS_TOKEN",
});

// Envía un mensaje
const result = await whatsapp.sendTextMessage("5215551234567", "¡Hola!");
console.log("Mensaje enviado:", result.messageId);

Funciones principales

  • sendTextMessage(numero, texto) - Envía texto
  • uploadMedia(archivo, tipo) - Sube imágenes/videos
  • getMediaInfo(id) - Info de archivos
  • downloadMedia(url) - Descarga archivos

Ejemplo completo: Flujo de pedido en WhatsApp

import { createWhatsAppService } from "@hectorbliss/whatsapp-sdk";
import fs from "fs";

const whatsapp = createWhatsAppService({
  phoneNumberId: "TU_PHONE_NUMBER_ID",
  accessToken: "TU_ACCESS_TOKEN",
});

// 1. Cliente inicia conversación
async function manejarPedidoCompleto(cliente: string, pedido: any) {
  // Bienvenida
  await whatsapp.sendTextMessage(
    cliente,
    "🍕 ¡Hola! Gracias por contactar a *Pizza Express*. ¿Qué te gustaría ordenar?"
  );

  // Mostrar menú con imágenes
  const menuImage = fs.readFileSync("menu-pizzas.jpg");
  const { mediaId } = await whatsapp.uploadMedia(menuImage, "image/jpeg");
  
  await whatsapp.sendTextMessage(
    cliente,
    `📋 Aquí está nuestro menú. ¿Qué pizza te gustaría?\n\nEjemplo: "Quiero una grande de pepperoni con extra queso"`
  );

  // 2. Confirmar pedido
  const confirmacion = `✅ Pedido confirmado:\n\n🍕 ${pedido.pizza} (${pedido.tamaño})\n📍 ${pedido.direccion}\n💰 Total: $${pedido.total}\n\n¿Todo está correcto? Responde "SÍ" para proceder.`;
  await whatsapp.sendTextMessage(cliente, confirmacion);

  // 3. Procesar pago (simulado)
  await whatsapp.sendTextMessage(
    cliente,
    "💳 Procesando tu pago... ✅ Pago aprobado!"
  );

  // 4. Preparación y seguimiento
  await whatsapp.sendTextMessage(
    cliente,
    `👨‍🍳 Tu pizza está en preparación! Tiempo estimado: 25-30 minutos.\n\n📱 Puedes seguir tu pedido en tiempo real.`
  );

  // 5. Imagen de preparación
  const preparacionImage = fs.readFileSync("pizza-preparacion.jpg");
  const { mediaId: prepMediaId } = await whatsapp.uploadMedia(preparacionImage, "image/jpeg");

  // 6. Envío
  await whatsapp.sendTextMessage(
    cliente,
    `🚗 ¡Tu pedido está en camino!\n\n🕐 Llegará en aproximadamente 15 minutos\n📍 Dirección: ${pedido.direccion}\n\nGracias por elegirnos! 🍕`
  );

  // 7. Entrega final
  await whatsapp.sendTextMessage(
    cliente,
    `🎉 ¡Pedido entregado!\n\nEsperamos que disfrutes tu pizza. ¿Cómo estuvo todo? Tu opinión nos ayuda a mejorar.\n\n📞 Para futuros pedidos, ¡aquí estaremos!`
  );
}

// Uso real
const pedidoEjemplo = {
  pizza: "Pepperoni con extra queso",
  tamaño: "Grande",
  direccion: "Calle Principal 123",
  total: 289.50
};

// Ejecutar el flujo completo
manejarPedidoCompleto("5215551234567", pedidoEjemplo)
  .then(() => console.log("🚀 Flujo de pedido completo ejecutado"))
  .catch(console.error);

Documentación avanzada

Ver docs/advanced-usage.md para ejemplos más complejos.

Licencia

MIT