https://github.com/blawby/blawby-ai-chatbot
https://github.com/blawby/blawby-ai-chatbot
cloudflare-api cloudflare-pages cloudflare-workers legaltech preact
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/blawby/blawby-ai-chatbot
- Owner: Blawby
- License: mit
- Created: 2025-06-12T04:24:46.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-10-02T05:02:35.000Z (9 days ago)
- Last Synced: 2025-10-02T05:29:39.159Z (9 days ago)
- Topics: cloudflare-api, cloudflare-pages, cloudflare-workers, legaltech, preact
- Language: TypeScript
- Homepage: https://ai.blawby.com
- Size: 3.59 MB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Legal Intake Chatbot - Cloudflare Workers AI
A production-ready legal intake chatbot built with Cloudflare Workers AI, featuring intelligent conversation handling, step-by-step information collection, and automated matter creation with payment integration.
## ๐ **Quick Start**
### Prerequisites
- Node.js 18+ and npm
- Cloudflare account with Workers, D1, KV, and R2 access
- Wrangler CLI installed globally### Installation
1. **Clone and install**
```bash
git clone
cd preact-chat-gpt-interface
npm install
```2. **Set up environment**
```bash
cp .dev.vars.example .dev.vars
# Edit .dev.vars with your API keys
```3. **Start development**
```bash
npm run dev:full # Both frontend and worker
```4. **Deploy to Cloudflare**
```bash
wrangler deploy
```## ๐ฏ **Key Features**
- **๐ค AI-Powered Legal Intake**: Intelligent conversation handling with Cloudflare Workers AI
- **๐ Lead Qualification**: Smart filtering to ensure quality leads before contact collection
- **โ๏ธ Matter Classification**: Automatic legal issue categorization (Employment, Family, Personal Injury, etc.)
- **๐ฐ Payment Integration**: Automated consultation fee collection with team configuration
- **๐จโ๐ผ Human Review Queue**: Lawyer oversight for urgent/complex matters
- **๐ฑ Mobile-First Design**: Responsive interface with modern UI/UX
- **๐ File Upload Support**: Photos, videos, audio, documents (25MB max) with camera capture
- **๐ Authentication**: Google OAuth and email/password with Better Auth
- **๐ Production Security**: OWASP-compliant headers and validation## ๐๏ธ **Architecture**
```
Frontend (Preact) โ Cloudflare Workers โ AI Agent โ Tool Handlers โ Actions
```**Core Components:**
- **Legal Intake Agent**: Self-contained AI with built-in memory and tool execution
- **Tool Handlers**: Modular functions for contact collection, matter creation, lawyer review
- **Team Configuration**: Dynamic payment and service configuration per team
- **Review Queue**: Human-in-the-loop system for lawyer oversight## ๐ ๏ธ **Technology Stack**
- **Frontend**: Preact, TypeScript, Tailwind CSS
- **Backend**: Cloudflare Workers, D1 Database, KV Storage, R2 Object Storage
- **AI**: Cloudflare Workers AI (Llama 3.1 8B)
- **Auth**: Better Auth with Google OAuth & Email/Password
- **Deployment**: Cloudflare Workers## ๐งช **Testing**
```bash
# Start development servers (required for tests)
npm run dev:full# Run tests
npm run test:conversation # Core AI functionality tests
npm test # All unit/integration tests
npm run test:watch # Watch mode
npm run test:i18n # Smoke test to confirm translations switch correctly
npm run lint:i18n # Validate locale files stay in sync
```## ๐ **Project Structure**
```
โโโ src/ # Frontend (Preact + TypeScript)
โ โโโ components/ # UI components
โ โโโ hooks/ # Custom React hooks
โ โโโ utils/ # Utility functions
โโโ worker/ # Backend (Cloudflare Workers)
โ โโโ agents/ # AI agent definitions
โ โโโ routes/ # API endpoints
โ โโโ services/ # Business logic
โ โโโ utils/ # Worker utilities
โโโ tests/ # Test files
โโโ public/ # Static assets
```## ๐ง **Configuration**
### Environment Variables
Copy `.dev.vars.example` to `.dev.vars` and add your API keys:
- `BLAWBY_API_TOKEN` - Blawby services API key
- `LAWYER_SEARCH_API_KEY` - Lawyer search API key
- `CLOUDFLARE_API_TOKEN` - Cloudflare operations API key
- `RESEND_API_KEY` - Email notifications API key### Internationalization
- The app boots with English (`en`) and supports Spanish (`es`) out of the box. Locale assets live in `src/locales//.json`.
- Use the Settings โ General page to switch the UI language and to trigger auto-detection.
- Contributors can follow the workflow in `docs/i18n.md` to add new strings or locales.
- Run `npm run lint:i18n` before committing to make sure every locale contains the same keys as the English baseline.### Team Management
Teams are managed via REST API:
```bash
# List teams
curl -X GET http://localhost:8787/api/teams# Create team (requires admin token)
curl -X POST http://localhost:8787/api/teams \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"slug": "new-team", "name": "New Team", "config": {"aiModel": "llama"}}'
```## ๐ **Security**
- OWASP-compliant security headers
- File upload validation (25MB max)
- Rate limiting (60 requests/minute)
- Input sanitization
- Secure session management with Better Auth## ๐ค **Contributing**
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Submit a pull request## ๐ **License**
MIT License - see [LICENSE](LICENSE) file for details.
---
**Built with โค๏ธ using Cloudflare Workers AI and Preact**