# HalaVoice AI Agent for Salla — MVP Roadmap

## Phase 1: Foundation (Week 1-2)
### Core Salla Integration
- [x] OAuth 2.0 Easy Mode installation flow
- [x] Webhook receiver (HMAC-SHA256 verification)
- [x] Salla Merchant API client with token refresh
- [ ] Store onboarding wizard (Salla Embedded SDK iframe)
- [ ] App Settings page (Arabic UI)

### Database & Models
- [x] Migrations (17 tables)
- [x] Eloquent models with relationships
- [ ] Seeders for default automation rules
- [ ] Indexes for common queries

### HalaVoice Bridge
- [x] HalaVoice REST API client (mock mode)
- [ ] Production HalaVoice connection setup
- [ ] Mock-to-live toggle mechanism

## Phase 2: Voice Calls (Week 3-4)
### COD Confirmation
- [ ] `order.created` webhook → dispatch `MakeOutboundCall` job
- [ ] Arabic voice script: confirm order
- [ ] Handle "confirmed" response → update Salla order status
- [ ] Handle "cancelled" response → cancel order via Salla API
- [ ] Call transcript storage
- [ ] Call summary via AI

### Abandoned Cart Recovery (Voice)
- [ ] `abandoned.cart` webhook → dispatch `RecoverAbandonedCart` job
- [ ] Voice script: cart reminder (first call)
- [ ] Voice script: follow-up with offer
- [ ] Track conversion (cart → order)

## Phase 3: WhatsApp (Week 5-6)
### WhatsApp Messaging
- [ ] Order confirmation message template
- [ ] Shipping update notification template
- [ ] Delivery confirmation template
- [ ] Abandoned cart reminder template
- [ ] Review request template
- [ ] Arabic messages with proper formatting

### Delivery
- [ ] `shipment.created` webhook → `SendWhatsAppMessage`
- [ ] `order.status.updated` → appropriate message
- [ ] Two-way WhatsApp conversation handling
- [ ] Human escalation trigger

## Phase 4: Dashboard & Reports (Week 7-8)
### Embedded Dashboard
- [ ] Overview page with KPIs
- [ ] Call logs with filtering
- [ ] WhatsApp logs
- [ ] Recovered revenue tracking
- [ ] Automation rules management
- [ ] Billing & usage display

### API Endpoints
- [ ] REST API for call logs
- [ ] REST API for WhatsApp logs
- [ ] REST API for settings management
- [ ] REST API for transcripts and summaries

## MVP Gate Criteria
- [ ] 10+ test stores installed
- [ ] 100+ COD confirmation calls completed
- [ ] 20+ abandoned carts recovered
- [ ] 200+ WhatsApp messages sent
- [ ] Dashboard loads under 2 seconds
- [ ] Webhook processing under 30 seconds
- [ ] Zero PII leaks (audit)
