Website chat widget with your documents
Put a chat on your website that answers visitors from your own documents: product sheets, FAQ, prices, opening hours. Visitors need no account. The widget comes from the AnythingLLM template (Knowledge & RAG category).
Use only material you would publish anyway. Anything in the widget's workspace can end up in an answer to a stranger. Never point a website widget at the same knowledge base as a staff bot: use a separate AnythingLLM service, not just a separate workspace.
How it is built
An AnythingLLM service has two web addresses, both on a small gate (nginx) in front of the app:
| Address | What answers there | Who can open it |
|---|---|---|
https://<service>.<panel domain> (main) | The whole AnythingLLM app: admin settings, workspaces, documents, API | Only people signed in to the panel, for good. There is no Make public for it. |
https://<service>-widget.<panel domain> (widget) | Only the widget: its script, its stylesheet and the chat calls of an embed. Everything else returns 404. | Private at first. Public after you click Make widget public. |
The widget address passes exactly these requests to AnythingLLM 1.17.0 and nothing else:
GET /embed/anythingllm-chat-widget.min.jsand.min.cssPOST /api/embed/<embed id>/stream-chat(a visitor's question)GETandDELETE /api/embed/<embed id>/<session id>(a visitor's chat history, and "reset chat")
The embed management calls under the same /api/embed/ path (the list of all widget conversations, editing an embed) never pass the widget address.
Set it up
Deploy AnythingLLM from the catalog. Choose an AI source at deploy (the panel's AI, Local AI or your own key): it is filled in as AnythingLLM's Generic OpenAI provider. You can also pick a provider later in AnythingLLM under Settings → AI Providers.
Set a password at once. A fresh AnythingLLM has no password, and anyone who reaches it can run it. The main address is behind panel sign-on, but turn on Settings → Security → Password protection or Multi-User Mode (one account per person) anyway.
Create a workspace for the website, for example "Website FAQ", and upload the public documents.
Create an embed: Settings → Chat Embed → Create embed.
- Workspace: the website workspace.
- Chat mode: Query. The widget then answers only from the documents and says so when they hold no answer, instead of chatting freely with the model.
- Allowed domains: your website's address, for example
https://www.example.com. The template refuses every request from an embed without allowed domains, so this field is required in practice. AnythingLLM compares the visitor's browserOrigin, so list every variant you serve (https://example.comandhttps://www.example.com). - Max chats per day and Max chats per session: caps on what strangers can cost you. Each answer is a call to your AI source.
Copy the embed's ID. AnythingLLM shows a code snippet; the ID is the value of
data-embed-id. Do not use that snippet itself: it points at the main address, which visitors cannot open.On the service page in the panel, open the Website widget card (in the setup drawer) and paste the ID. The card shows the code with the widget address filled in:
<script data-embed-id="<embed id>" data-base-api-url="https://<service>-widget.<panel domain>/api/embed" src="https://<service>-widget.<panel domain>/embed/anythingllm-chat-widget.min.js"> </script>The panel never asks AnythingLLM for the ID and never stores it; it only fills in the text.
Click Make widget public on the service page. The app restarts once.
Paste the code into your website, just before
</body>, and test it from your website (not from the panel: the allowed-domains check needs your website's origin).
Limits and abuse
- Allowed domains stop other websites from using your widget in their pages. They do not stop someone calling the widget address directly with a forged
Origin, so the daily and per-session limits are the real cost cap. - Turn an embed off (Enabled) in AnythingLLM to stop the widget at once without touching the panel. The widget address keeps answering 404 for everything else.
- AnythingLLM keeps every widget conversation (Settings → Chat Embed, chat history). Say so in your website's privacy notice.
- Telemetry to AnythingLLM is switched off in this template.
Upgrades and older services
AnythingLLM keeps its password, the chosen AI provider and its encryption key in a settings file. The template keeps that file in the service's data volume, so a redeploy keeps them.
An AnythingLLM service deployed before the widget address existed has only one address. Its Website widget card says so: deploy AnythingLLM again to get the widget address.
See also
- Knowledge & RAG templates
- App access: private by default and Make public