Deploy Your Agent

Web Widget

Embed your AI agent as a chat widget on any website with a single script tag or the JavaScript SDK.

Web Widget

Deploy your agent as a floating chat widget on any website. Users click the bubble to open a conversation — no backend required on your side.

Quick Setup

Add one line to your HTML:

<script
  src="https://app.thinnest.ai/embed.js"
  data-agent-id="YOUR_AGENT_ID"
  async
></script>

This adds a chat bubble to the bottom-right corner of your page.

Finding Your Agent ID

  1. Open your agent in the thinnestAI dashboard
  2. Go to the Deploy tab
  3. Copy the Agent ID or Publish ID shown in the embed code

Configuration Options

Customize the widget with data- attributes on the script tag:

AttributeTypeDefaultDescription
data-agent-idstringRequiredYour agent's public ID
data-keystringPublishable key (recommended for production)
data-themestring"light""light" or "dark"
data-positionstring"bottom-right""bottom-right" or "bottom-left"
data-primary-colorstring"#FF4D00"Brand color (hex)
data-titlestringAgent nameChat window title
data-subtitlestringSubtitle below the title
data-placeholderstring"Type a message..."Input placeholder
data-welcome-messagestringFirst message shown to users
data-user-idstringAuto-generatedIdentify users for session continuity

Full Example

<script
  src="https://app.thinnest.ai/embed.js"
  data-agent-id="agent_abc123"
  data-theme="dark"
  data-primary-color="#6366F1"
  data-title="Acme Support"
  data-subtitle="We typically reply in seconds"
  data-placeholder="Ask us anything..."
  data-welcome-message="Hi! How can I help you today?"
  async
></script>

Publishable Keys (Production)

For production deployments, use publishable keys instead of raw agent IDs. Keys add origin restrictions and usage limits.

Create a Key

curl -X POST https://api.thinnest.ai/widget-keys \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_abc123",
    "name": "Production Key",
    "allowed_origins": ["https://www.example.com"],
    "config": {
      "max_sessions_per_day": 1000,
      "max_messages_per_session": 100
    }
  }'

Use the Key

<script
  src="https://app.thinnest.ai/embed.js"
  data-key="pk_live_abc123xyz"
  async
></script>

Key Features

FeatureDescription
Origin RestrictionsWidget only loads on specified domains
Session QuotasLimit daily sessions to control costs
Message LimitsCap messages per session
Voice MinutesLimit voice interaction time

Lead Capture

Collect user information before they start chatting.

Enable Lead Capture

  1. Go to your agent's Deploy tab
  2. Open Web Embed settings
  3. Enable Lead Collection
  4. Add fields: email, phone, name, company, or custom fields
  5. Mark fields as required or optional

Supported Field Types

TypeDescription
textSingle-line text input
emailEmail with validation
phonePhone number input
textareaMulti-line text
selectDropdown with predefined options

Users must complete the form before chatting. All captured data appears in your Leads dashboard.

JavaScript SDK

For deeper integration, use the SDK directly:

npm install @thinnestai/embed-sdk
import { ThinnestAI } from '@thinnestai/embed-sdk';

const agent = new ThinnestAI({
  agentId: 'agent_abc123',
  theme: 'light',
  position: 'bottom-right',
});

agent.open();
agent.sendMessage('Hello!');

agent.on('message', (msg) => {
  console.log('Agent replied:', msg.content);
});

SDK Methods

MethodDescription
open()Open the chat widget
close()Close the chat widget
toggle()Toggle open/close
sendMessage(text)Send a message programmatically
on(event, callback)Subscribe to events
destroy()Remove the widget
setUser(userId)Set user identifier

SDK Events

EventPayloadDescription
message{ role, content }New message received
openWidget opened
closeWidget closed
error{ code, message }Error occurred
session_start{ sessionId }New session started

Styling

Override default styles with CSS variables:

:root {
  --thinnestai-primary: #6366F1;
  --thinnestai-bg: #ffffff;
  --thinnestai-text: #1a1a1a;
  --thinnestai-border-radius: 12px;
  --thinnestai-font-family: 'Inter', sans-serif;
}

Custom Launcher

Replace the default bubble with your own button:

<button onclick="agent.toggle()">Chat with us</button>

<script>
  const agent = new ThinnestAI({
    agentId: 'agent_abc123',
    showLauncher: false,
  });
</script>

Testing

  1. Locally — Use localhost as an allowed origin
  2. Dashboard — Click Test Chat on your agent page
  3. Test file — Create a minimal HTML page with the embed script

Best Practices

  • Use publishable keys in production with origin restrictions
  • Set session and message limits to control costs
  • Add a welcome message to increase engagement
  • Match your brand colors and position
  • Test on mobile to verify responsive layout

On this page