# Chatbot SaaS — Multi-tenant WhatsApp AI assistant (Laravel)

A multi-tenant SaaS where every business (tenant) connects its WhatsApp Business number,
uploads its own knowledge base, and an OpenAI-powered bot answers customers 24/7 —
handing the chat to a human agent when needed.

See **[PLAN.md](PLAN.md)** for the full plan and progress checklist.

## Features (so far)

- Multi-tenancy (single DB, `tenant_id` scope) with a subdomain per tenant: `{tenant}.chatbot.test`
- WhatsApp Cloud API webhook (signature check, idempotency, status updates)
- OpenAI Responses API + per-tenant vector store (`file_search`) for knowledge-grounded replies
- Knowledge base: text, Q&A, website URL, files — plus a "Test your bot" playground
- Bot settings: persona, language, fallback, human-handover keywords
- Conversations inbox: agent replies, take over / give back to bot
- Super admin panel: tenants list, add, suspend, delete
- Landing page

## Stack

Laravel 12 · PHP 8.2+ · MySQL 8 · Livewire 3 / Volt · Tailwind CSS · Pest

## Getting started

```bash
composer install
npm install && npm run build
cp .env.example .env && php artisan key:generate
# set DB_*, OPENAI_API_KEY, META_* in .env
php artisan migrate --seed

# keep a queue worker running (knowledge processing + WhatsApp replies)
php artisan queue:work --queue=webhooks,ai,outbound,knowledge,default
```

- Central site: `http://chatbot.test` (landing, sign-up, `/admin`)
- Tenant dashboard: `http://{subdomain}.chatbot.test`
- WhatsApp webhook: `https://<your-domain>/webhooks/whatsapp`

## Tests

```bash
php artisan test
```
