What they are
The SLAtech API now has two official client libraries: @slatech/bot-sdk for JavaScript and TypeScript, and slatech for Python. Instead of building each HTTP request yourself, you call a method - client.ask(...), client.knowledge.add_text(...), client.data.leads(...) - and get typed results back.
- JavaScript / TypeScript: runs on Node.js 18 and later and in browsers. ES module and CommonJS builds, with type declarations.
- Python: Python 3.10 and later, with a synchronous client (
SLAtech) and an asynchronous one (AsyncSLAtech) that have the same methods.
Each library covers all 19 operations of the public API: asking (the whole answer, a streamed answer, a question about an image, feedback), the knowledge base (files, pages, sitemaps, text, jobs, deletion), leads, conversations and analytics. Both also verify the signature of the webhooks SLAtech sends to your server.
They do not add anything the API does not do: the same key, the same scopes, the same limits and the same errors apply. Neither library retries a failed request on its own - the errors carry what you need to decide, such as the wait time of a rate-limit refusal.
Install
npm install @slatech/bot-sdk
pip install slatech
You also need an API key. Create one in the dashboard under API Keys: each key belongs to one site and has its own scopes. The getting started guide explains which scopes each call needs.
Example 1: ask a question (TypeScript)
import { SLAtechClient } from "@slatech/bot-sdk";
const client = new SLAtechClient({ apiKey: process.env.SLATECH_API_KEY! });
const result = await client.ask({ question: "Do you open on Saturdays?" });
console.log(result.answer);
for (const source of result.sources ?? []) console.log(source.title, source.sourceUrl);
The answer comes with the sources it was grounded in. For an answer that appears while it is being written, use client.askStream(...).
Example 2: keep the knowledge base in sync (Python)
from slatech import SLAtech
with SLAtech() as client: # the key comes from SLATECH_API_KEY
job = client.knowledge.add_text(
"Opening hours: Sunday to Thursday, 9:00-18:00.",
source_url="https://example.com/opening-hours",
)
print(client.knowledge.get_job(job["jobId"])["status"]) # 0 pending ... 2 completed
# When the page is removed from your site:
client.knowledge.delete_by_source_url("https://example.com/opening-hours")
Adding content runs in the background, so each add returns a job to check. Text sent again with the same source URL updates that one document, which makes a sync from your own system safe to repeat.
Example 3: verify a webhook (TypeScript)
import express from "express";
import { verifyWebhookSignature } from "@slatech/bot-sdk/webhooks";
const app = express();
app.post("/slatech-webhook", express.raw({ type: "application/json" }), (req, res) => {
if (!verifyWebhookSignature(req.body, req.get("X-SLAtech-Signature"), process.env.SLATECH_WEBHOOK_SECRET!)) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body.toString("utf8"));
// handle event...
res.sendStatus(204);
});
Pass the body exactly as it arrived, before any JSON parsing. In Python the same check is verify_webhook_signature(raw_body, signature_header, secret).
Keep write and data keys on your server
The JavaScript library runs in a browser, but only the ask methods belong there. A key with the ingest scope can change what your assistant answers, and a key with data:read reads leads with their contact details.
Open source
Both libraries are open source under the Apache License 2.0.
- Client libraries guide: every method with the operation it calls, streaming, errors and webhooks
- @slatech/bot-sdk on npm
- slatech on PyPI
- API reference