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

@igris262626/chatbot

v0.1.10

Published

Worktual chatbot SDK with React chat widget — POST /chatbot

Readme

@igris262626/chatbot

Server client and React chat widget for a Worktual chatbot.

The subdomain and its knowledge base are created in My Account. Upload the PDF there. This SDK does not create a super domain, create a subdomain, or upload a document. My Account gives you the numeric subdomain_id, starting at 1000. Pass that number to chat and end session.

Both the server client and the widget call the gateway.

POST {WORKTUAL_API_URL}/chatbot
Authorization: Bearer <token>
Content-Type: application/json
Idempotency-Key: <one key for this action>
subdomain: 1000

The server uses the org access token. The widget uses an embed token minted outside this client. Do not point baseUrl or apiBase at the chatbot service port 8000.

Install

npm install @igris262626/chatbot react react-dom

Requires Node.js 18 or newer. react and react-dom are only required for the widget.

Environment

Put these on the server. Do not put the access token in frontend code.

WORKTUAL_ACCESS_TOKEN=the-org-access-token
WORKTUAL_API_URL=<gateway-url>
WORKTUAL_SUPER_DOMAIN=YOUR_SUPER_DOMAIN

WORKTUAL_API_URL is the gateway origin Worktual gives you. When it is omitted, the client uses the default gateway.

Chat from the server

import { WorktualClient } from "@igris262626/chatbot";

const client = new WorktualClient({
  accessToken: process.env.WORKTUAL_ACCESS_TOKEN!,
  superDomainId: process.env.WORKTUAL_SUPER_DOMAIN!,
  baseUrl: process.env.WORKTUAL_API_URL,
});

const shop = "1000";
const reply = await client.chat(shop, "What are your return policies?", "s1");
console.log(reply.answer, reply.citations);

const followUp = await client.chat(shop, "Summarize that in one sentence", reply.session_id);
await client.endSession(shop, followUp.session_id);

shop is the numeric subdomain_id from My Account. reply is { session_id, answer, citations, usage }. usage is the provider token total for that turn: prompt_tokens (prompt, history, tool schemas, and tool results), completion_tokens (answer, tool-call arguments, and thinking), reasoning_tokens (the thinking portion, already inside completion_tokens), and total_tokens (prompt_tokens plus completion_tokens). Reuse session_id for the next question. sessionId is required on every chat call. Shop credits stay one per successful turn.

A question sends:

{
  "action": "chat",
  "session_id": "s1",
  "query": "What are your return policies?",
  "tools": []
}

End the session

The widget does this when the panel closes. Call it from the server when you already have the session id.

await client.endSession(shop, reply.session_id);
{
  "action": "end_session",
  "session_id": "s1"
}

Widget

Pass an embed token to the page. This client does not mint that token.

import { WorktualChat } from "@igris262626/chatbot/ui";
import "@igris262626/chatbot/ui/styles.css";

export function SupportChat({ token }: { token: string }) {
  return (
    <WorktualChat
      token={token}
      superDomainId={process.env.NEXT_PUBLIC_SUPER_DOMAIN!}
      subDomainId="1000"
      apiBase={process.env.NEXT_PUBLIC_API_URL}
      name="Lola"
      subtitle="Conversational Assistant"
      poweredBy="Worktual"
      color="#000000"
      logoUrl="https://cdn.example.com/logo.png"
      greeting="Hi — how can I help you today?"
    />
  );
}

token, superDomainId, and subDomainId are required. subDomainId is the numeric subdomain_id from My Account. apiBase is the same gateway origin. When it is omitted, the widget uses the default gateway.

The widget creates session_id when the panel opens and sends chat for each visitor message. Closing the panel sends end_session for that same id. The answer it shows is answer, with citations when the gateway returns them.

| Prop | Required | Purpose | |---|---|---| | token | yes | Embed token for the page | | superDomainId | yes | Tenant id | | subDomainId | yes | Numeric subdomain_id from My Account | | apiBase | no | Gateway origin. Defaults to the Worktual gateway | | name, subtitle, poweredBy | no | Header text. Defaults are Lola, Conversational Assistant, Worktual | | greeting | no | First assistant message | | color | no | Brand hex color | | logoUrl | no | Header and avatar image | | defaultOpen | no | Panel starts open. Default true | | sttUrl | no | Optional speech-to-text URL. When omitted, the mic is not active | | className | no | Extra CSS class |

Server methods

Every method posts to /chatbot. Pass the numeric subdomain_id.

| Method | Action | What it does | |---|---|---| | chat(subdomainId, message, sessionId, tools?) | chat | Asks a question. sessionId is required | | endSession(subdomainId, sessionId) | end_session | Clears that session |

The client creates one Idempotency-Key per action. If that HTTP call times out or the gateway returns 408, 429, 502, 503, or 504, the client retries once with the same key.

Errors

401 means the access token was rejected. 403 means the tenant is not allowed to call this API. 429 means the rate limit was hit. The error text can include X-Request-ID and X-RateLimit-Remaining when the gateway sends those headers.