Public Chat
A public share needs no backend code. Visitors chat without logging in; each browser gets its own anonymous identity and sees its history again on the next visit.
In all examples replace https://rag.example.com with your Ragty base URL and shr_XXXXXXXXXXXXXXXXXXXXXXXX with your share ID.
Option A: Web component (recommended)
Embed the web component
Load the component once per page:
<script type="module" src="https://rag.example.com/embed-assets/v1/m8ty-chat.js" crossorigin="anonymous"></script>Place the element where the chat should appear and give it a height:
<m8ty-chat share="shr_XXXXXXXXXXXXXXXXXXXXXXXX" locale="de" theme="auto" style="display:block;height:600px"></m8ty-chat>Open the page from one of the allowed origins. The greeting of the chat appears and visitors can start asking questions.
The snippet in the Ragty integration guide additionally contains an integrity="sha384-…" attribute. It guarantees that exactly the reviewed version of the script runs on your page. After a Ragty update the hash changes: copy the new snippet, or omit integrity if you prefer automatic updates.
Option B: iframe
Query parameter | Values | Default |
|---|---|---|
|
| Browser language |
|
|
|
The frame only loads on the allowed origins; on any other site the browser refuses to display it.
Java server-side templates (Velocity)
If your pages are rendered with Apache Velocity, keep the share configuration in your Java code and render the snippet from a template. Put the values into the Velocity context once per request:
Always output values through
$esc.html(…)/$esc.url(…), even if they come from your own configuration.Do not add user data (
$user, e-mail, customer number) to a public template — a public chat never receives a user.Remove
nonce="…"if your CSP does not use nonces.
Content Security Policy
If your page sends a Content-Security-Policy header, add the Ragty origin:
Directive | Needed for |
|---|---|
| Web component |
| Web component (API calls) |
| iframe |
The component itself needs no 'unsafe-inline' and no 'unsafe-eval'; it is compatible with Trusted Types.
How the anonymous identity works
On first use Ragty sets a cookie on the Ragty domain:
HttpOnly; Secure; SameSite=None; Partitioned. It is bound to your site, invisible to any JavaScript (including yours) and renewed on every visit.Clearing cookies, using a private window or switching device starts a new, empty chat. Browsers that block partitioned third-party cookies start a new chat on every page load.
History is deleted automatically after the retention period of the share.
Verify the integration
Open the page on an allowed origin and ask a question — the answer streams in and cited sources are listed below it.
Reload the page — the previous conversation is shown again.
Open the same page from a non-allowed origin (for example a local test page) — the chat must not work (iframe blank, CORS error in the console for the web component).