Jez | Jeremy Dawes
Back to projects
ai-agent active

L2Chat Widget

Drop-in AI chat widget for web applications. Multi-provider support, 21+ rich components, Shadow DOM isolation, and full theming.

PreactCloudflare WorkersR2ElevenLabs

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.

4
AI Providers
21+
Components
22
Themes
~60KB
Bundle Size

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:

AI Providers4

ElevenLabs, AI SDK v5, n8n, Workers AI

Rich Components21

Cards, carousels, forms, pricing

Theming22

Preset themes + full colour control

Features8

Voice, streaming, tool calls

Providers

ProviderUse Case
ElevenLabsVoice AI with WebRTC, tool calls
Vercel AI SDK v5Standard LLM chat endpoints
n8nWebhook-based workflow automation
Workers AICloudflare AI via proxy

Rich Content Components

The widget renders 21+ interactive components from agent responses:

ComponentDescription
Product CardsE-commerce cards with ratings, prices
Image CarouselSwipeable gallery with navigation
Date PickerCalendar with time selection
Video EmbedYouTube, Vimeo, direct video
Location CardStatic maps with directions
Contact CardTeam member info with actions
Pricing TablesTier comparison with CTAs
Progress StepperMulti-step status display
Review CardsCustomer testimonials
Comparison TableFeature comparison grid
Countdown TimerLimited-time offer urgency
Slider InputBudget/quantity selection
File UploadDocument upload with drag-drop
QR CodeScannable codes with copy
Signature CaptureDigital signature collection
Accordion/FAQExpandable Q&A sections
TimelineChronological event display
Alert BoxesInfo, warning, success, error
External LinksStyled CTA buttons
Inline FormsStructured data collection
Dynamic SuggestionsClickable 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