# Sales Leads Admin

Laravel admin (`https://admin.ecom01.rs`) now includes a Sales Leads module for OpenClaw ingest and sales follow-up.

## Roles

- `admin`: full Filament access, leads, categories, users, roles.
- `sales`: Leads menu only; can update `status`, `email_draft_html`, and `notes_internal`.

Seed roles and local test data:

```bash
php artisan db:seed --class="Database\\Seeders\\Sales\\RolesAndUsersSeeder"
php artisan db:seed --class="Database\\Seeders\\Sales\\SalesLeadCategorySeeder"
php artisan db:seed --class="Database\\Seeders\\Sales\\SalesLeadTestSeeder"
```

## OpenClaw Token

Create the service token on production and store it as an OpenClaw secret:

```bash
php artisan openclaw:token openclaw-ingest@ecom01.rs --name=openclaw-ingest
```

The token is printed once. Use it as a Bearer token with the `leads:ingest` ability.

## Ingest API

```bash
curl -X POST https://admin.ecom01.rs/api/leads/ingest \
  -H "Authorization: Bearer <SANCTUM_TOKEN>" \
  -H "Content-Type: application/json" \
  --data @payload.json
```

The endpoint is idempotent by `pib`, then by normalized `website` if `pib` is missing. Categories are sent as `category_slugs`, matched by slug, and created if missing.

Example payload:

```json
{
  "company_name": "Hotel Gallus",
  "pib": "123456789",
  "licenses": 5,
  "locations": 2,
  "apr_code": "5510",
  "annual_revenue": 123456789.01,
  "email": "info@hotel.rs",
  "phone": "+381 11 1234567",
  "website": "https://hotel.rs",
  "city": "Beograd",
  "country": "RS",
  "source": "biznisoft",
  "source_ref": "https://biznisoft.rs/clients/123",
  "status": "pending",
  "category_slugs": ["hotel", "integracije"],
  "email_draft_html": "<p>Pozdrav...</p>",
  "notes_internal": "Imaju PMS, verovatno BizniSoft"
}
```
