Web Widget
Add your assistant's chat interface to a website with one script.
The Web Widget displays your assistant as a floating chat window on a website. Assistant Core provides the interface, streaming, conversation history, Markdown, dark mode, and mobile layout.
Before you begin
- You can manage the assistant in the Admin Panel.
- Your current plan includes the Web Widget feature.
- You know the website's exact origin, such as
https://www.example.com.
An origin consists of the protocol, hostname, and port when present. It does not include a path, query parameter, or fragment.
1. Allow the website
- Open the Admin Panel and select your assistant.
- Go to Channels → Web Widget.
- Under 1. Allow Websites, enter the complete origin.
- Select Add Website, then select Save Changes.
Valid origin examples:
https://www.example.com
https://preview.example.com
http://localhost:3000Add production, staging, preview, and local development origins separately. https://example.com and https://www.example.com are different origins.
2. Install the widget
Under 2. Install the Widget, select Copy Snippet. The generated snippet already contains the assistant ID and API base for your environment:
<script
src="https://cdn.assistantcore.com/embed/embed.js"
data-assistant-id="YOUR_ASSISTANT_ID"
data-api-base="https://api.assistantcore.com"
async
></script>Add the script once near the end of <body> or in your framework's root layout. The async attribute lets the widget load without blocking the page's primary content.
HTML
<body>
<!-- Website content -->
<script
src="https://cdn.assistantcore.com/embed/embed.js"
data-assistant-id="YOUR_ASSISTANT_ID"
data-api-base="https://api.assistantcore.com"
async
></script>
</body>Next.js
Add the script to the root layout so client-side navigation does not reload it:
import Script from "next/script"
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
<Script
src="https://cdn.assistantcore.com/embed/embed.js"
data-assistant-id="YOUR_ASSISTANT_ID"
data-api-base="https://api.assistantcore.com"
strategy="lazyOnload"
/>
</html>
)
}3. Allow visitor attachments (optional)
By default, website visitors can send text only. To let them attach files, turn on Visitor Attachments → Allow file uploads on the same page. The setting is saved as soon as you toggle it.
- Supported files: images (PNG, JPEG, GIF, WebP), PDF, Word, Excel, CSV, and text files.
- Maximum size: 25 MB per file.
- Uploaded files are stored in your workspace and count toward your usage.
Script attributes
| Attribute | Required | Description |
|---|---|---|
src | Yes | Widget loader URL. Use the URL generated by the Admin Panel. |
data-assistant-id | Yes | Your assistant's UUID. |
data-api-base | Yes | The Assistant Core API origin for your environment. |
data-lang | No | Interface language: en or vi. Auto-detected by default. |
If the page has <html lang="vi">, the widget selects Vietnamese when data-lang is not set.
Privacy
The widget stores a visitor identifier in local storage and sends chat content to your assistant for processing. Before publishing:
- Update your website's privacy policy when required.
- Do not include secrets or data you are not permitted to process in test messages.
- Review consent requirements for the markets where you operate.
Verify the installation
- Open the site from the exact origin you allowed.
- Confirm that the chat launcher appears.
- Send a test message and confirm that the response streams.
- Test on mobile and in dark mode.
Troubleshooting
| Symptom | Resolution |
|---|---|
| The widget does not appear | Confirm the script is included once and is not blocked by your Content Security Policy. |
| The website is not allowed | Compare the browser origin with Admin; check www, protocol, and port. |
| The widget calls the wrong environment | Copy the snippet again from Admin and verify data-api-base. |
| Origin changes are not applied | Select Save Changes, reload the page, and try again. |
When a deployment creates a new preview URL, add its origin before sharing it with QA or customers.