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

@zenzap-co/chat-adapter-zenzap

v0.1.4

Published

Zenzap adapter for Chat SDK

Downloads

160

Readme

chat-adapter-zenzap

npm version npm downloads

A Chat SDK adapter for Zenzap — build platform-agnostic chatbots that work with Zenzap's messaging API.

Installation

npm install chat chat-adapter-zenzap

Quick start

import { Chat } from "chat";
import { createZenzapAdapter } from "chat-adapter-zenzap";

const chat = new Chat({
  userName: "my-bot",
  adapters: {
    zenzap: createZenzapAdapter(),
  },
});

chat.onNewMention(async (thread, message) => {
  await thread.subscribe();
  await thread.post("Hello! I'm now watching this thread.");
});

chat.onSubscribedMessage(async (thread, message) => {
  await thread.post(`You said: ${message.text}`);
});

Or with explicit configuration:

const chat = new Chat({
  userName: "my-bot",
  adapters: {
    zenzap: createZenzapAdapter({
      apiKey: "your-api-key",
      apiSecret: "your-api-secret",
    }),
  },
});

Environment variables

| Variable | Required | Description | Example | |---|---|---|---| | ZENZAP_API_KEY | Yes | API key (used as Bearer token) | zk_live_abc123... | | ZENZAP_API_SECRET | Yes | API secret (used for HMAC-SHA256 request signing) | zs_live_def456... | | ZENZAP_BASE_URL | No | API base URL | https://api.zenzap.co |

Configuration reference

| Option | Type | Default | Description | |---|---|---|---| | apiKey | string | process.env.ZENZAP_API_KEY | Zenzap API key | | apiSecret | string | process.env.ZENZAP_API_SECRET | Zenzap API secret for HMAC signing | | baseUrl | string? | https://api.zenzap.co | API base URL override | | userName | string? | "zenzap-bot" | Bot display name | | logger | Logger? | ConsoleLogger | Custom logger instance |

Platform setup

  1. Log in to the Zenzap admin panel.
  2. Navigate to Settings > API Keys.
  3. Click Create API Key — this generates a new bot user.
  4. Copy the API Key and API Secret from the creation dialog.
  5. Set the environment variables ZENZAP_API_KEY and ZENZAP_API_SECRET, or pass them to createZenzapAdapter().

See the Zenzap API docs for full details on authentication and request signing.

Receiving messages

Zenzap uses long polling rather than webhooks. There are two ways to receive messages:

Long polling (standalone / long-running servers)

import { ZenzapAdapter } from "chat-adapter-zenzap";

await chat.initialize();

const adapter = chat.adapters.zenzap as ZenzapAdapter;
adapter.startPolling();

// Later:
// adapter.stopPolling();

Webhook route (serverless / Vercel)

In serverless environments you can't run a persistent polling loop. Instead, poll on a schedule and forward updates to a webhook handler.

Webhook handler (app/api/chat/zenzap/route.ts):

import { chat } from "@/lib/chat";

export async function POST(request: Request) {
  return chat.webhooks.zenzap(request);
}

Cron-triggered poller (app/api/cron/poll-zenzap/route.ts):

import { ZenzapApiClient } from "chat-adapter-zenzap";

const api = new ZenzapApiClient({
  apiKey: process.env.ZENZAP_API_KEY!,
  apiSecret: process.env.ZENZAP_API_SECRET!,
});

export async function GET(request: Request) {
  const offset = /* read from KV / database */;

  const updates = await api.getUpdates(offset, 50, 0);

  for (const update of updates.updates) {
    await fetch(`${process.env.VERCEL_URL}/api/chat/zenzap`, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(update),
    });
  }

  /* persist updates.nextOffset to KV / database */

  return Response.json({ processed: updates.updates.length });
}

vercel.json:

{
  "crons": [{ "path": "/api/cron/poll-zenzap", "schedule": "* * * * *" }]
}

Note: Per-minute crons require Vercel Pro. Persist nextOffset in Vercel KV, Upstash Redis, or a database to avoid reprocessing events across invocations.

Supported features

| Feature | Supported | |---|---| | Send messages | Yes | | Receive messages | Yes (long polling or webhook) | | Fetch message history | Yes (cursor-based pagination) | | Reactions | Yes (add only — removal in progress) | | Attachments (receive) | Yes | | File uploads (send) | In progress | | Edit messages | In progress | | Delete messages | In progress | | Typing indicators | In progress | | Streaming | In progress |

Exports

import {
  ZenzapAdapter,          // Adapter class
  ZenzapApiClient,        // Standalone API client
  ZenzapFormatConverter,  // Markdown <-> mdast converter
  createZenzapAdapter,    // Factory function
} from "chat-adapter-zenzap";

// Types
import type {
  ZenzapAdapterConfig,
  ZenzapThreadId,
  ZenzapMessage,
} from "chat-adapter-zenzap";

Development

npm install
npm run build        # Build with tsup
npm run typecheck    # Type check
npm test             # Run tests
npm run dev          # Watch mode
npm run pack:check   # Verify package contents

Publishing

Releases are managed via GitHub Actions. Trigger a release from the Actions tab:

  • Stable release: Creates a version-bump PR. Merging it tags and publishes to npm with the latest tag.
  • Dev snapshot: Publishes immediately with a dev tag (e.g. 0.1.0-dev.abc1234).

Requires an NPM_TOKEN secret in the repo settings.

License

MIT