ProductMarch 6, 2026·9 min read

Embeddable Chat Widget: From Zero to Production in 5 Minutes

Citai Team

March 6, 2026 · 9 min read

One line of code, a complete assistant

<script src="https://citai.ai/widget.js"
  data-api-key="sk-your-key"
  data-theme="light"
  data-position="bottom-right"
  data-welcome-message="Hi! How can I help you?">
</script>

That’s it. Your website now has an AI assistant with access to your entire knowledge base. No custom backend needed, no React, no dependencies.

Embeddable widget: 3 steps — copy snippet, configure, go live

Technical architecture

Shadow DOM: total isolation

The widget uses closed Shadow DOM. This means your CSS doesn’t affect the widget, the widget’s CSS doesn’t affect your site. No conflicts with Bootstrap, Tailwind, or any framework.

SSE Streaming in real time

Responses arrive token by token via Server-Sent Events using fetch + ReadableStream. No WebSocket, no extra libraries. Users see the response building in real time.

Session persistence

Conversations are saved in localStorage. If the user closes and returns, they pick up where they left off. History loads from the server automatically.

Full visual configuration

Parameter Description Example
data-theme Visual theme light, dark, auto
data-position Widget corner bottom-right, bottom-left
data-primary-color Main color #3b82f6
data-logo Your logo URL https://your-site.com/logo.png
data-welcome-message Initial message Hi! How can I help you?

Advanced features

Pre-chat form

Capture name, email, or other data before the conversation. Configurable per field: required or optional.

Why pre-chat? It identifies the user before the conversation. If escalated to human, your team already has name and email without asking again.

Conversation starters

Suggested buttons that appear when the widget opens. Each starter fires a query against your KB directly.

Business hours

Define days and hours. After hours: capture form with name, email, and subject + custom message.

Proactive triggers

The widget can open automatically based on time spent, scroll percentage, or URL patterns.

Smart escalation

  • Automatic: By low confidence threshold
  • Manual: “Talk to a human” button always visible
  • Webhooks: Instant notification with full conversation context

Multimedia FAQs

Images, videos, links, and carousels rendered directly in the chat.

Implementation tip: Start with the basic widget (API key only) and gradually add configuration. You don't need to set up everything upfront.

Industry templates

Citai includes 4 pre-designed templates: E-commerce, SaaS, Education, and Health — each with optimized starters and welcome messages.

30sinstallation time
Shadow DOMno CSS conflicts
SSEreal-time streaming
4industry templates

Install your widget in 30 seconds. Create your API key →

Try Citai for free

Create your intelligent knowledge base in minutes. No credit card required.

Create free account