# ITR Chatbot (PHP + JS)

Responsive WhatsApp support panel with:
- inbox/chat UI (`/platform`)
- dashboard (`/`)
- webhook endpoint (`/webhook`)
- MySQL-backed users/chats/messages

## Stack

- PHP 8.1+
- Vanilla JavaScript (responsive UI)
- MySQL
- Apache (with `mod_rewrite`)

## 1) Configure env

Create `.env` in project root:

```env
APP_BASE_URL=http://46.202.190.214/itr-chatbot
WHATSAPP_VERIFY_TOKEN=your_verify_token
WHATSAPP_ACCESS_TOKEN=your_whatsapp_access_token
WHATSAPP_PHONE_NUMBER_ID=your_phone_number_id
MYSQL_URL=mysql://USER:PASSWORD@127.0.0.1:3306/itr_chatbot
```

## 2) Create database schema

```bash
mysql -u root -p itr_chatbot < database.sql
```

## 3) Apache requirements

Enable rewrite module:

```bash
sudo a2enmod rewrite
sudo systemctl reload apache2
```

Allow `.htaccess` overrides in your VirtualHost (`AllowOverride All`).

## 4) URLs

- Dashboard: `http://YOUR_HOST/itr-chatbot/`
- Platform UI: `http://YOUR_HOST/itr-chatbot/platform`
- Login: `http://YOUR_HOST/itr-chatbot/login.php`
- Health: `http://YOUR_HOST/itr-chatbot/health`
- Webhook: `http://YOUR_HOST/itr-chatbot/webhook`

Default login (auto-seeded on first request):
- username: `admin`
- password: `123`

## 5) Meta webhook setup

- Callback URL: `https://YOUR_DOMAIN/itr-chatbot/webhook` (recommended HTTPS)
- Verify token: same as `.env` `WHATSAPP_VERIFY_TOKEN`

## Notes

- If Apache serves project from different path, update `APP_BASE_URL`.
- This version is PHP-native and does not require Node.js, PM2, or Redis.
