Quickstart Guide
This guide will get you from zero to a working chat widget in under 5 minutes.Prerequisites
Before you begin, make sure you have:- Node.js 20+ and npm 10+ installed
- A Convex account (free at convex.dev)
- An OpenAI API key (platform.openai.com)
New to Convex? Sign up takes 30 seconds with GitHub auth. Create a new project after signing in.
Installation
Clone and install dependencies
Configure environment variables
Copy the example environment file:Edit Copy this URL to
.env with your credentials:.env
Getting your Convex URL
Runnpx convex dev once to create a dev deployment. Convex will display your URL:CONVEX_URL in your .env file.Generate Convex types
Generate TypeScript types from your Convex schema:This creates type definitions in
convex/_generated/ used by the backend.Start Convex development server
In a terminal window, start Convex:Keep this running. Convex will sync your schema and functions to the cloud.
Convex provides the real-time database that stores conversations and messages.
Test the Widget
Now that everything is running, let’s test the chat widget.Option 1: Built-in Test Page
Open the test page included with the dashboard:- A chat button in the bottom-right corner
- Click to open the chat panel
- Type a message and get an AI response
Option 2: Embed in Your Own Page
Create a simple HTML file to test the widget:test-chat.html
The
data-api-key must match WIDGET_API_KEY from your .env file.View Conversations in Dashboard
After sending a few test messages:Log in
Enter the password from
DASHBOARD_PASSWORD in your .env file (default: change-me-admin-password)Customize the Widget
The widget accepts these data attributes:| Attribute | Description | Default |
|---|---|---|
data-api-url | Backend chat endpoint | Required |
data-api-key | Widget API key | Required |
data-title | Header text | "Assistant" |
data-welcome-message | First message shown | "Hi! Ask me anything..." |
data-input-placeholder | Input field placeholder | "Type your message..." |
data-position | "left" or "right" | "right" |
data-accent-color | Primary color (hex) | "#0ea5e9" |
Example: Custom Branding
Test the Headless API
Prefer to build your own UI? Test the REST endpoints:Next Steps
Learn the Architecture
Understand how Convex, Express, and the widget communicate
Deploy to Production
Deploy the backend, dashboard, and Convex to cloud providers
API Reference
Complete reference for all chat and admin endpoints
Customize the Widget
Customize widget appearance, colors, and positioning
Troubleshooting
Widget doesn't appear on the page
Widget doesn't appear on the page
Check these common issues:
- Verify backend is running:
curl http://localhost:4000/health - Check browser console for JavaScript errors
- Confirm the script URL is correct:
http://localhost:4000/widget/chat-widget.js - Ensure
data-api-urlanddata-api-keyattributes are set
401 Unauthorized errors
401 Unauthorized errors
Convex connection errors
Convex connection errors
Make sure:
npm run dev:convexis running in a separate terminalCONVEX_URLin.envmatches the URL shown in Convex dev output- You’ve run
npm run codegento generate types
Dashboard login not working
Dashboard login not working
Verify
DASHBOARD_PASSWORD in .env. The login uses this exact value.If you recently changed it, restart the dashboard:Rate limit errors (429)
Rate limit errors (429)
The backend limits requests by IP address. Default: 30 requests per minute.Adjust in
.env: