Embeddable Widget

Add AI chat widget to your website.

Overview

Features:

  • Floating chat button (customizable position)

  • Mobile-responsive (full-screen on mobile, bubble on desktop)

  • Session persistence (conversation history stored 30 days)

  • Customizable theme (light/dark/auto)

  • File upload support (max 10MB, PDF/images)

Bundle size: 45KB gzipped Load time: <50ms (async, non-blocking) Browser support: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+

Quick Start

Get Widget Code

  1. Twig → Agents → [Agent] → Deploy tab

  2. Click Embed Widget

  3. Copy generated script tag

Install

Paste before </body> tag:

Expected result: Chat button appears bottom-right corner (customizable)

Load time: Widget loads asynchronously (~45KB, cached after first load)

Configuration

Basic Configuration

Advanced Configuration

Customization

Styling

Theme Selection

Light Mode:

Dark Mode:

Auto (respects system):

Custom Colors

Custom CSS

Positioning

Language & Text

User Context

Identifying Users

Pass user information for personalized responses:

Session Persistence

JavaScript API

Opening/Closing

Sending Messages Programmatically

Events

Updating Configuration

Advanced Features

File Upload

Proactive Messages

Analytics Integration

Custom Actions

Mobile Optimization

The widget is automatically mobile-responsive:

  • Desktop: Floating chat bubble

  • Mobile: Full-screen overlay

  • Tablet: Adaptive sizing

Mobile-specific options:

Performance

Lazy Loading

Widget loads asynchronously by default:

Bundle Size

  • Initial load: ~45KB (gzipped)

  • Lazy-loaded on first interaction

  • Cached by browser

Load Time Impact

  • < 50ms on fast connections

  • Does not block page render

  • No impact on Core Web Vitals

Security

Content Security Policy

Add to your CSP:

Data Privacy

  • No cookies set (uses sessionStorage)

  • GDPR compliant

  • User data encrypted

  • No tracking without consent

Examples

React Application

Vue.js Application

Next.js Application

Troubleshooting

Widget Not Appearing

Symptom: No chat button visible on page

Diagnostic steps:

  1. Browser DevTools → Network tab → verify widget.js loaded (200 status)

  2. Console tab → check for errors (e.g., "Failed to load widget")

  3. Verify data-agent-id matches agent ID from Twig (format: agent_abc123)

  4. Check ad blocker not blocking (disable temporarily)

Fix: Correct agent ID, check script placement (must be in <body> not <head>)


Symptom: Widget shows "Agent not found"

Cause: Invalid agent ID or agent deleted

Fix: Verify agent exists: Twig → Agents → check list for agent ID


Symptom: Widget appears but styling broken

Cause: CSS conflicts or z-index issues

Fix: Add to your CSS:

Next Steps

Last updated