Worktual Assist SDK (Without UI)
Raw chatbot client. It asks the same RAG as the widget and returns the answer, citations, and token usage. It does not render a chat UI.
Contact Us
Overview
The shop and its documents are created in My Account. subDomainId is the numeric subdomain id, starting at 1000.
Install
npm i @worktual_limited/chatbot-wuiChat
import { ChatClient } from "@worktual_limited/chatbot-wui";
const client = new ChatClient({
accessToken: "identity-jwt",
superDomainId: "4204",
subDomainId: "1002",
baseUrl: "https://unified-api.worktual.com",
});
const reply = await client.chat("What are your return policies?", "s1");
console.log(reply.answer, reply.citations);
await client.endSession(reply.session_id);chat posts JSON to POST {baseUrl}/chatbot-wui with action: "chat". endSession posts action: "end_session". Both send Authorization, Content-Type, Idempotency-Key, and subdomain. Reuse session_id for the next question in the same conversation.
reply.usage is the provider token total for that turn. prompt_tokens includes the prompt, history, tool schemas, and tool results. completion_tokens includes the answer, tool-call arguments, and thinking. reasoning_tokens is the thinking portion and is already inside completion_tokens. total_tokens is prompt_tokens plus completion_tokens. Shop credits stay one per successful turn.
A failed response throws ChatError with status and the response body. 408, 429, 502, 503, and 504 are retried once with the same idempotency key.
Do not ship the access token in the browser for production apps. Call this SDK from a server.
In this document
Worktual Assist SDK (Without UI)
Overview
Install
Chat
↑ Back to top