Embed Widget & SDK
Deploy your AI agent as a chat widget on any website. The embed system provides a drop-in script tag for quick setup and a JavaScript API for programmatic integrations.Quick Setup
Add a single line of code to embed the chat widget:Widget Configuration
Script Tag Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
data-publishable-key | string | Required | Your publishable widget key |
data-agent-id | string | Required | Your agent’s public ID |
data-widget-type | string | "chat" | Widget type: "chat", "voice", or "combined" |
data-api-url | string | — | Target API URL (default handles this automatically) |
[!NOTE] The appearance (theme, colors, welcome message) is managed securely via your Agent Studio → Deploy settings, preventing unauthorized customization.
Example: Full Configuration
Publishable Keys
For production deployments, you must use publishable keys to authenticate your widget.Create a Publishable Key
Response
Key Security Features
| Feature | Description |
|---|---|
| Origin Restrictions | Only allows embedding from specified domains |
JavaScript SDK
For deeper integration, include the widget package:Installation
window.ThinnestAI:
SDK Methods
| Method | Description |
|---|---|
open() | Open the chat widget |
close() | Close the chat widget |
sendMessage(text) | Send a message to the agent |
startVoice() | Open the widget and start voice call |
newChat() | Start a fresh chat session |
destroy() | Remove the widget from the page |
SDK Events
Listen for widget events on the globalwindow object:
| Event | Description |
|---|---|
thinnestai.session.started | New session initialized |
thinnestai.session.restored | Existing session restored |
thinnestai.message.sent | User sent a message |
thinnestai.message.received | Agent response received |
thinnestai.call.started | Voice call started |
thinnestai.call.ended | Voice call ended |
thinnestai.error | Error occurred |
thinnestai.opened | Widget opened |
thinnestai.closed | Widget closed |
thinnestai.lead.captured | Lead form submitted |
Agent API Keys
For server-to-server integrations (not browser-based), use Agent API Keys:Styling & Customization
Widget customization is done entirely through the Agent Studio Deploy Panel → Design tab. This leverages an isolated Shadow DOM framework ensuring consistent rendering across environments. You can customize:- General look and feel (Colors, Typography)
- Launcher style and icons
- Popover messages and branding removal
Testing Your Widget
- Local testing — Add
localhostas an allowed origin for your widget key. - Preview in dashboard — Click Test Chat on your agent’s page.
- Test HTML file — Create a minimal HTML file with the embed script.
Best Practices
- Use publishable keys in production with correct origin restrictions.
- Add a welcome message to guide users.
- Match your brand using the Design settings.
- Test on mobile to verify the widget’s layout on your site.

