L2Chat Widget
Drop-in AI chat widget for web applications. Multi-provider support, 21+ rich components, Shadow DOM isolation, and full theming.
Overview
A production-ready AI chat widget that drops into any website with a single script tag. Supports multiple AI providers, renders rich interactive content, and isolates styles with Shadow DOM to prevent CSS conflicts.
The Problem
Adding AI chat to websites typically means:
- Complex SDK integration with provider-specific code
- CSS conflicts with existing site styles
- Limited customisation options
- No rich content beyond plain text
- Building the same widget repeatedly for different projects
Businesses need a drop-in solution that “just works” across any site.
Solution
Single script tag deployment with extensive customisation:
ElevenLabs, AI SDK v5, n8n, Workers AI
Cards, carousels, forms, pricing
Preset themes + full colour control
Voice, streaming, tool calls
Providers
| Provider | Use Case |
|---|---|
| ElevenLabs | Voice AI with WebRTC, tool calls |
| Vercel AI SDK v5 | Standard LLM chat endpoints |
| n8n | Webhook-based workflow automation |
| Workers AI | Cloudflare AI via proxy |
Rich Content Components
The widget renders 21+ interactive components from agent responses:
| Component | Description |
|---|---|
| Product Cards | E-commerce cards with ratings, prices |
| Image Carousel | Swipeable gallery with navigation |
| Date Picker | Calendar with time selection |
| Video Embed | YouTube, Vimeo, direct video |
| Location Card | Static maps with directions |
| Contact Card | Team member info with actions |
| Pricing Tables | Tier comparison with CTAs |
| Progress Stepper | Multi-step status display |
| Review Cards | Customer testimonials |
| Comparison Table | Feature comparison grid |
| Countdown Timer | Limited-time offer urgency |
| Slider Input | Budget/quantity selection |
| File Upload | Document upload with drag-drop |
| QR Code | Scannable codes with copy |
| Signature Capture | Digital signature collection |
| Accordion/FAQ | Expandable Q&A sections |
| Timeline | Chronological event display |
| Alert Boxes | Info, warning, success, error |
| External Links | Styled CTA buttons |
| Inline Forms | Structured data collection |
| Dynamic Suggestions | Clickable response options |
Features
Shadow DOM Isolation
Complete style isolation prevents CSS conflicts with host sites. The widget’s styles never leak out, and site styles never affect the widget.
Streaming Responses
Real-time text display as the AI responds. Shows thinking indicators during processing and tool call visibility for transparency.
Voice Support
Optional voice input/output with animated orb indicator (ElevenLabs provider). WebRTC connection for low-latency conversation.
Full Theming
22 preset themes with light/dark/system modes. Every colour customisable via HTML attributes:
<l2-chat
agent-id="your-agent"
theme="dark"
primary-color="#06b6d4"
header-bg="#0f172a"
user-message-bg="#0ea5e9"
/>
Architecture
Client Website
↓
<script src="widget.l2chat.com/widget.js">
↓
<l2-chat> Web Component
↓
Shadow DOM (style isolation)
↓
Preact App
↓
Provider Selection:
├── ElevenLabs (WebRTC/WebSocket)
├── AI SDK v5 (SSE streaming)
├── n8n (SSE streaming)
└── Workers AI (via proxy)
↓
Rich Content Parser
↓
Interactive Components
Tech Stack
- Runtime: Preact (3KB vs React’s 40KB)
- Hosting: Cloudflare Workers + R2
- Voice: ElevenLabs SDK + WebRTC
- Markdown: Custom parser with DOMPurify
- Build: Vite with UMD/ESM outputs
- Styling: CSS-in-JS with CSS variables
Embedding
<!-- Add the widget script -->
<script src="https://widget.l2chat.com/widget.js"></script>
<!-- ElevenLabs provider (default) -->
<l2-chat agent-id="your-elevenlabs-agent-id"></l2-chat>
<!-- AI SDK v5 provider -->
<l2-chat provider="ai-sdk" api-endpoint="/api/chat"></l2-chat>
<!-- n8n provider -->
<l2-chat provider="n8n" webhook-url="https://n8n.example.com/webhook/xxx"></l2-chat>
Use Cases
Customer Support - AI-powered help desk with rich responses
Sales Assistants - Product recommendations with cards and pricing
Appointment Booking - Date pickers and calendar integration
Lead Qualification - Inline forms for structured data collection
Knowledge Bases - FAQ accordions and document embeds
Interested in a similar solution?
Let's talk about your project