SDK DocumentationWorktual Chatbot SDK

Worktual Chatbot SDK

Server client and React chat widget for a Worktual chatbot.

@worktual_limited/chatbot

Contact Us

Overview

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

Install

npm install @worktual_limited/chatbot react react-dom

Environment

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

Chat from the server

import { WorktualClient } from "@worktual_limited/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);
{
  "action": "chat",
  "session_id": "s1",
  "query": "What are your return policies?",
  "tools": []
}

End the session

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

Widget

import { WorktualChat } from "@worktual_limited/chatbot/ui";
import "@worktual_limited/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?"
    />
  );
}

Server methods

Errors

In this document
Worktual Chatbot SDK
Overview
Install
Environment
Chat from the server
End the session
Widget
Server methods
Errors
↑ Back to top