Liya Chat
Deploy a grounded AI chat assistant on any website in one script tag. Answers questions from your knowledge base — not from hallucinated generalities.
Liya Chat is a customer-facing AI assistant that answers questions from your uploaded knowledge — docs, FAQs, product content, policies. It deploys as a widget on any web page or as an API-driven backend for your own chat UI.
Domain: chat
Endpoint: POST /v1/run with pack: "liya-chat" or domain: "chat"
How Liya Chat works
Every message goes through four steps:
- Retrieval — semantic search over your uploaded knowledge base for that domain
- Grounding check — verifies the retrieved context is sufficient to answer confidently
- Response generation — answer generated with your configured persona and tone
- Source citation — response includes the source documents used
If the knowledge base doesn't have a clear answer, Liya Chat escalates rather than hallucinating.
Deployment options
| Option | How | Best for |
|---|---|---|
| Embed widget | One <script> tag in your HTML | Marketing site, help center, docs, SaaS product |
| API integration | POST /v1/run from your backend | Custom chat UI, mobile apps, internal tools |
Widget deployment (fastest path)
1. Create an embed token
In the dashboard, go to Deploy → Embed Tokens and create a token. You must specify at least one allowed origin (the domain your website runs on).
Or via API:
Response:
The full token is shown once only — copy it immediately.
2. Add the widget script
Paste this into the <head> or before </body> of your page:
The widget mounts automatically. No additional JavaScript required.
3. Customise the widget (optional)
| Attribute | Default | Options |
|---|---|---|
data-title | "Ask anything" | Any string |
data-placeholder | "Type a message..." | Any string |
data-position | "bottom-right" | "bottom-right" · "bottom-left" |
data-theme | "light" | "light" · "dark" |
API integration
For custom chat UIs, call POST /v1/run directly from your backend:
Response:
Pass session_id on follow-up messages to maintain conversation context.
Chat intents
| Intent | When to use |
|---|---|
answer_question | Specific factual question — returns grounded answer with sources |
general_chat | Open-ended conversation — more flexible, context-aware |
summarize | Summarise a document, page, or thread |
clarify | Ask Liya to explain or elaborate on a previous answer |
escalate | Hand off to a human agent — Liya wraps the session context |
Building your knowledge base
Liya Chat answers are only as good as what you've uploaded. Add your content:
Supported file formats: PDF, DOCX, TXT, plain text, JSON.
Embed token security
Embed tokens (liya_pub_*) are distinct from API keys:
- Origin-locked — requests from unlisted origins are rejected at the API layer
- Intent-scoped — the token can only call the intents you configure
- Rate-limited — default 60 RPM per token; configurable up to your plan limit
- Revocable — delete a token from the dashboard at any time; the widget stops working immediately
- Max 10 active tokens per tenant — rotate unused tokens
Embed tokens are safe to include in public HTML. They cannot access your API key, account settings, or non-chat intents.
Session limits
| Limit | Default | Plan |
|---|---|---|
| Max turns per session | 50 | All plans |
| Max tokens per session | 100,000 | All plans |
When a session's token budget is exhausted, Liya Chat returns a graceful escalation response rather than an error. A new session_id starts a fresh session.
Next steps
- Deploy Widget Guide — step-by-step widget integration with CORS and CSP notes
- Building a RAG Pipeline — populate your chat knowledge base
- Sessions and Memory — how multi-turn context works
- Configuration — customise the chat persona and tone