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

@hitheo/whatsapp

v0.2.2

Published

WhatsApp Business API adapter for the Theo AI orchestration API

Downloads

147

Readme

@hitheo/whatsapp

WhatsApp Business API adapter for the Theo AI orchestration API. Bridges WhatsApp Cloud API webhook events to POST /api/v1/completions and sends Theo's reply back through the Graph API.

Install

npm install @hitheo/whatsapp

Minimal Example

import express from "express";
import {
  createWhatsAppHandler,
  verifyWebhook,
  verifySignature,
} from "@hitheo/whatsapp";

const app = express();

const handle = createWhatsAppHandler({
  theoApiKey: process.env.THEO_API_KEY!,
  whatsappToken: process.env.WHATSAPP_TOKEN!,
  phoneNumberId: process.env.WHATSAPP_PHONE_ID!,
  appSecret: process.env.WHATSAPP_APP_SECRET!,
});

// Meta pings this on setup to verify you own the endpoint:
app.get("/whatsapp/webhook", (req, res) => {
  const challenge = verifyWebhook({
    mode: String(req.query["hub.mode"]),
    token: String(req.query["hub.verify_token"]),
    challenge: String(req.query["hub.challenge"]),
    verifyToken: process.env.WHATSAPP_VERIFY_TOKEN!,
  });
  if (challenge) return res.status(200).send(challenge);
  return res.sendStatus(403);
});

// Real webhook — verify signature BEFORE JSON.parse:
app.post(
  "/whatsapp/webhook",
  express.raw({ type: "application/json" }),
  async (req, res) => {
    const sig = req.header("x-hub-signature-256");
    if (!verifySignature(req.body, sig, process.env.WHATSAPP_APP_SECRET!)) {
      return res.sendStatus(401);
    }
    await handle(JSON.parse(req.body.toString("utf8")));
    res.sendStatus(200);
  },
);

Environment Variables

| Name | Required | Description | | --- | --- | --- | | THEO_API_KEY | yes | Theo API key (theo_sk_...). | | WHATSAPP_TOKEN | yes | Cloud API access token. | | WHATSAPP_PHONE_ID | yes | Your WhatsApp Business phone number ID. | | WHATSAPP_APP_SECRET | yes | Meta App Secret — used to verify X-Hub-Signature-256. | | WHATSAPP_VERIFY_TOKEN | yes | Shared secret for the GET verification handshake. |

Features

  • Text + images — text, captions, images, and image/* documents forwarded to Theo. Images are downloaded inside the adapter and sent as image_base64 — the Meta access token is never embedded in any URL that leaves your deployment.
  • Voice / audio — transcribed via Theo speech-to-text and appended to the prompt as text when enableVoice: true.
  • HMAC signature verificationverifySignature(rawBody, headerSig, appSecret) using timingSafeEqual. Must run on the raw body before JSON parsing.
  • Webhook challenge helperverifyWebhook({ mode, token, challenge, verifyToken }) returns the challenge string or null.
  • Conversation memory — per-phone-number conversation IDs. Default is in-process; pass conversationStore for Redis/DB.
  • Sanitized errors — completion failures are logged server-side; the user sees a generic "Something went wrong" message.
  • Chunked replies — >4000 char responses are split automatically.

Config Reference

createWhatsAppHandler({
  theoApiKey: "theo_sk_...",
  whatsappToken: "WHATSAPP_TOKEN",
  phoneNumberId: "PHONE_ID",
  appSecret: "APP_SECRET",                 // used by verifySignature() in your route
  theoBaseUrl: "https://hitheo.ai",        // override only for self-hosted
  mode: "auto",
  persona: "theo" | "none" | { system_prompt: "..." },
  skills: ["customer-support"],
  conversationStore: myRedisStore,         // optional
  enableVoice: false,                      // opt-in media forwarding
  maxChunkChars: 4000,
});

Docs

License

MIT