Replai_PRD_v2.docx
Replai
AI customer support and commerce platform
Product Requirements Document · v2.0
| Status | Stack | AI | Phases | |
|---|---|---|---|---|
| PRD Complete | React + Flask | Africa's Talking | Groq Llama 3 | 10 Total |
1. Overview & Purpose
The Problem
Most African businesses run on WhatsApp.
Customers text at 3am. Nobody replies. Sales die.
Replai fixes this — an AI agent that knows your business, handles customers, takes orders, and confirms M-Pesa payments while you sleep.
What It Is
A multi-tenant AI customer support and commerce platform delivered as:
-
WhatsApp agent
-
Web chat widget
-
Developer API
Who It's For
Small Business Owners
-
Want a no-code WhatsApp AI agent
-
Need 24/7 customer support
-
Want automated order handling
Developers
-
Want APIs for AI support
-
Need POS and inventory integrations
-
Want webhook-driven commerce flows
Why It's Different
Not a generic chatbot.
Replai’s agent understands:
-
Products
-
Prices
-
Business hours
-
Brand tone
-
Delivery zones
And handles real commerce:
-
Orders
-
M-Pesa confirmations
-
Customer support
Market
Every African business running on WhatsApp:
-
Salons
-
Boutiques
-
Hardware stores
-
Pharmacies
-
Restaurants
-
Freelancers
Millions of businesses still have zero 24/7 support infrastructure.
Built By
Isaac Bakari Juma
Jaribu Tech Solutions
2. Key Decisions Locked
| Area | Decision |
|---|---|
| Frontend | React + TailwindCSS |
| Backend | Flask + PostgreSQL + SQLAlchemy + Marshmallow |
| AI Model | Groq (Llama 3) |
| WhatsApp v1 | Africa's Talking |
| WhatsApp v2 | Become direct Meta BSP |
| Payments | M-Pesa Daraja + Paystack |
| Multi-tenancy | Full tenant isolation |
| Inventory (Small Biz) | Manual dashboard catalogue |
| Inventory (Developer) | API inventory sync |
| Authentication | JWT + API Keys + bcrypt |
| Trial System | 14-day free Pro trial |
| Super Admin | Separate secured admin portal |
| Pricing | Freemium |
3. Users & Their Goals
Small Business Owner
Goals
-
Never miss customer messages
-
Automatically confirm M-Pesa payments
-
Setup in under 10 minutes
-
Take over conversations manually anytime
-
Update products independently
-
Try before paying
Developer
Goals
-
Integrate using one API key
-
Sync inventory from POS
-
Receive order/payment webhooks
-
Reliable uptime
-
Clean docs
-
Ignore AI complexity entirely
Super Admin (Isaac)
Goals
-
Manage all tenants
-
Control pricing
-
Extend/revoke trials
-
View analytics
-
Toggle maintenance mode
-
Control platform feature flags
4. Features & Scope
AI Agent Capabilities
Customer Support
-
Product enquiries
-
Pricing questions
-
Business hours
-
Complaint escalation
-
After-hours responses
-
Human takeover handoff
Commerce
-
Order handling
-
M-Pesa instructions
-
Payment confirmations
-
Appointment booking
-
Delivery fee calculation
-
Swahili + English support
Business Onboarding Flow
Sign up
→ Verify email
→ Describe business
→ Add products
→ Connect WhatsApp
→ Trial starts
Developer Onboarding Flow
Sign up
→ Verify email
→ Get API key
→ Sync inventory
→ Set webhooks
→ Trial starts
Business Dashboard
Features
-
Conversations inbox
-
Live takeover
-
Orders management
-
Inventory CRUD
-
Agent editor
-
Analytics dashboard
-
Trial status tracker
Order & Payment Flow
Customer orders via chat
→ Agent creates order + reference
→ Sends M-Pesa instructions
→ Customer pays
→ Daraja webhook fires
→ Payment matched
→ Customer confirmed
→ Owner notified
→ Order appears in dashboard
Channels (v1)
-
WhatsApp Business
-
Web chat widget
-
REST API
Out of Scope (v1)
-
Replai holding payments directly
-
Real-time auto inventory sync for small businesses
-
AI self-learning
-
Multi-location businesses
-
Instagram/Messenger/Telegram
-
Mobile app
-
Trial fraud detection
5. Sample Conversation
Boutique Shoe Shop — 3AM
Customer
Habari, mna Nike Air Force 1 size 42 nyeupe?
Replai Agent
Habari! Ndio, Nike AF1 size 42 white iko. Bei KES 8,500. Delivery au pickup?
Customer
Delivery. Niko Kasarani
Replai Agent
Order summary:
Nike AF1 size 42 white — KES 8,500
Delivery Kasarani — KES 200Total = KES 8,700
Lipa:
Till 247247
Ref: ORD-4821Confirm hapa baada ya kulipa.
Customer
Nimelipa
Replai Agent
KES 8,700 confirmed!
Order ORD-4821
Delivery Kasarani
Expected leo 2–4pm.Asante!
6. Database Schema
tenants
| Field |
|---|
| id |
| business_name |
| type |
| plan |
| api_key |
| whatsapp_number |
| payment_type |
| payment_number |
| agent_context |
| is_active |
products
| Field |
|---|
| id |
| tenant_id |
| name |
| description |
| price |
| stock_count |
| is_available |
| created_at |
inventory_sync
| Field |
|---|
| id |
| tenant_id |
| webhook_url |
| sync_mode |
| last_synced_at |
orders
| Field |
|---|
| id |
| tenant_id |
| order_ref |
| customer_phone |
| items |
| total_amount |
| delivery_location |
| delivery_fee |
| payment_status |
| payment_method |
| mpesa_transaction_id |
| order_status |
| created_at |
payments
| Field |
|---|
| id |
| tenant_id |
| order_id |
| amount |
| mpesa_ref |
| payment_type |
| confirmed_at |
conversations
| Field |
|---|
| id |
| tenant_id |
| customer_phone |
| messages |
| status |
| last_message_at |
users
| Field |
|---|
| id |
| tenant_id |
| password_hash |
| role |
trials
| Field |
|---|
| id |
| tenant_id |
| started_at |
| expires_at |
| status |
| days_remaining |
platform_settings
| Field |
|---|
| key |
| value |
| updated_at |
| updated_by |
admin_users
| Field |
|---|
| id |
| password_hash |
| role |
7. API Routes
Public & Tenant Routes
| Method | Route | Purpose | Auth |
|---|---|---|---|
| POST | /auth/register | Register account | Public |
| POST | /auth/login | Login | Public |
| GET | /dashboard/conversations | Tenant conversations | JWT |
| GET | /dashboard/orders | Tenant orders | JWT |
| GET | /dashboard/products | Product inventory | JWT |
| POST | /dashboard/products | Add product | JWT |
| PATCH | /dashboard/products/:id | Edit product | JWT |
| DELETE | /dashboard/products/:id | Delete product | JWT |
| POST | /dashboard/agent | Update AI context | JWT |
| GET | /dashboard/trial | Trial status | JWT |
| POST | /webhooks/whatsapp/:id | Incoming WhatsApp | AT Signature |
| POST | /webhooks/mpesa/:id | Daraja callback | Daraja |
| POST | /api/chat | Developer chat API | API Key |
| POST | /api/inventory/sync | Inventory sync | API Key |
| GET | /api/orders | Fetch orders | API Key |
Super Admin Routes
| Method | Route | Purpose | Auth |
|---|---|---|---|
| POST | /admin/login | Admin login | Public |
| GET | /admin/tenants | View tenants | Admin JWT |
| PATCH | /admin/tenants/:id | Manage tenant | Admin JWT |
| GET | /admin/trials | View trials | Admin JWT |
| PATCH | /admin/trials/:id | Modify trial | Admin JWT |
| GET | /admin/settings | Platform settings | Admin JWT |
| PATCH | /admin/settings/:key | Update settings | Admin JWT |
| GET | /admin/analytics | Platform analytics | Admin JWT |
8. Folder Structure
replai/
├── client/
│ ├── src/pages/
│ ├── src/dashboard/
│ ├── src/developer/
│ └── src/admin/
├── server/
│ ├── models/
│ ├── schemas/
│ ├── routes/
│ ├── services/
│ ├── config.py
│ └── extensions.py
├── widget/
├── migrations/
├── main.py
├── requirements.txt
└── .env
9. Environment Variables
| Variable | Purpose |
|---|---|
| DATABASE_URL | PostgreSQL DB |
| JWT_SECRET_KEY | Tenant JWT secret |
| ADMIN_JWT_SECRET | Admin JWT secret |
| GROQ_API_KEY | Groq AI |
| AT_API_KEY | Africa's Talking |
| AT_USERNAME | Africa's Talking username |
| AT_WHATSAPP_NUMBER | WhatsApp sender |
| DARAJA_CONSUMER_KEY | Daraja key |
| DARAJA_CONSUMER_SECRET | Daraja secret |
| DARAJA_SHORTCODE | M-Pesa shortcode |
| PAYSTACK_SECRET_KEY | Billing |
| REPLAI_API_KEY_SECRET | API key salt |
| FRONTEND_URL | Tenant frontend |
| ADMIN_URL | Admin frontend |
10. Build Phases
| Phase | Focus |
|---|---|
| 1 | Foundation |
| 2 | AI Agent Core |
| 3 | WhatsApp Integration |
| 4 | Orders & Payments |
| 5 | Business Dashboard |
| 6 | Developer API |
| 7 | Web Widget |
| 8 | Landing + Onboarding |
| 9 | Trial System |
| 10 | Super Admin Panel |
11. Trial Flow
Why It Matters
Businesses need to experience value before paying.
14-day Pro access:
-
No credit card
-
No friction
-
Full feature access
Trial Timeline
| Day | Event |
|---|---|
| Day 0 | Trial starts |
| Day 7 | Reminder email |
| Day 12 | Upgrade urgency |
| Day 14 | Downgrade to free tier |
| Post-expiry | Upgrade restores Pro |
Super Admin Trial Controls
-
Extend trial
-
Revoke trial
-
Change global trial duration
-
View conversion rates
12. Pricing Roadmap
Free Plan
-
500 messages/month
-
1 WhatsApp number
-
1 agent
-
Basic dashboard
-
Order management
Pro Plan — KES 2,500/month
-
5,000 messages/month
-
3 channels
-
3 agents
-
Live takeover
-
Full analytics
-
Priority support
API Plan — KES 0.50/message
-
500 free/month
-
Webhooks
-
Inventory sync
-
POS integrations
-
Full documentation
Trial Policy
Every signup gets:
-
14-day Pro access
-
No card required
-
Instant activation
Controlled dynamically through:
platform_settings
No redeploy required.
Status
Replai PRD v2.0
✅ Approved and ready to build
Next Step
Phase 1 — Foundation
-
Folder structure
-
Flask foundation
-
PostgreSQL setup
-
Multi-tenant authentication
Built by Isaac Bakari Juma
Jaribu Tech Solutions
jumaisaq@gmail.com