Engage • Retain • Recover
Features • Architecture • Getting Started • Documentation • Roadmap
- Overview
- Key Features
- Architecture
- Workflow Diagram
- Technology Stack
- Getting Started
- Usage
- API Documentation
- Roadmap
- License
Kineo is an enterprise-grade real-time AI voice agent designed specifically for e-commerce customer retention. It bridges the gap between traditional support and modern AI by leveraging Google's Gemini 2.0 Flash model to engage customers in natural, low-latency voice conversations.
Unlike standard chatbots, Kineo actively assesses churn risk in real-time and dynamically deploys retention strategies—such as personalized offers and cashback incentives—directly into the user interface during the conversation.
- Zero-Latency Voice - Browser-native Web Speech API for instant interaction without plugins
- Dynamic Risk Scoring - "Churn Engine" evaluates sentiment and history in real-time
- Visual Retention Cards - UI adapts to conversation context (e.g., popping up a Discount Card)
- Seamless Integration - Connects with Order Management Systems (OMS) for live tracking
- Environment-Aware - Auto-configures for Local, Render, or Railway deployments
- Full Observability - Structured session logs stored in Firestore for analytics
Browser-Native STT/TTS:
- No Third-Party Audio Plugins - Uses standard
SpeechRecognitionandSpeechSynthesisAPIs - Queue-Based Audio - Prevents audio collisions between apology messages and offers
- Visual Feedback - Real-time waveforms and transcription updates
- WebSocket Streaming - Full duplex communication for immediate agent responses
The backend implements a dedicated scoring engine:
- Sentiment Analysis - Evaluates user tone and frustration levels
- History Weighting - Factors in customer tenure and return history
- Instant Categorization - Low, Medium, or High risk tiers assigned millisecond-by-millisecond
- Triggered Responses - Risk scores drive the agent's negotiation strategy
Kineo moves beyond text by controlling the UI:
- Smart UI Cards - Agent can push rich JSON payloads to the frontend
- Interactive Elements - Users can click "Accept Offer" buttons generated by the agent
- Visual Cues - Marquee animations and color shifts based on conversation state
- Context Awareness - Offers match the specific complaint (e.g., specific product refund vs general credit)
Simulates a full enterprise OMS:
- Live Status Checks - "Where is my order?" queries hit the
order_service - Return Eligibility - Automatically validates return windows
- Shipping Updates - Provides tracking details and dates
- Webhook Support - Ready to receive real external updates
- Firestore Integration - Every turn of conversation is structured and saved
- Metadata Tagging - Transcripts tagged with final churn score and outcome
- Analytics Ready - Data structure optimized for future model fine-tuning
Kineo follows a high-performance modular architecture:
┌─────────────────────────────────────────────────────────────────┐
│ Frontend (Browser Client) │
│ • Web Speech API (STT/TTS) │
│ • WebSocket Client (WSS/WS) │
│ • Dynamic UI Cards (Vanilla JS/Neo-Brutalist CSS) │
│ • Environment-Aware Config │
└────┬────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Backend Server (FastAPI) │
│ • Uvicorn ASGI Server │
│ • WebSocket Endpoint (/session) │
│ • REST API Endpoints │
└────┬──────────────────────┬──────────────────────┬──────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────┐
│ Session Manager│ │ Churn Engine │ │ Order Service │
│ │ │ │ │ │
│ • State Mgmt │ │ • Risk Scoring │ │ • OMS │
│ • Context │ │ • Offer Logic │ │ • Status Updates │
└─────────────────┘ └─────────────────┘ └─────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ External Services │
│ • Google Gemini 2.0 Flash (Multimodal AI) │
│ • Google Cloud Firestore (Session/User DB) │
└─────────────────────────────────────────────────────────────────┘
graph TD
User[User] -->|Voice Input| Browser[Frontend Client]
Browser -->|Web Speech API| BrowserLogic[Client Logic]
BrowserLogic -->|WebSocket JSON| API[FastAPI Backend]
subgraph Backend Services
API -->|Context & Intent| Agent[Gemini 2.0 Agent]
Agent -->|Query Data| DB[(Firestore)]
Agent -->|Calc Risk| Churn[Churn Scoring Engine]
Agent -->| Check Orders| Orders[Order Management System]
Churn -->|Risk Score & Incentives| Agent
end
Agent -->|Natural Language Response| API
Agent -->|UI Directives| API
API -->|WebSocket Event| BrowserLogic
BrowserLogic -->|SpeechSynthesis API| User
BrowserLogic -->|Render Offer Cards| UI[Visual Interface]
- Core: HTML5, CSS3 (Neo-Brutalist Design)
- Logic: Vanilla JavaScript (ES6+)
- Audio: Web Speech API (
webkitSpeechRecognition,speechSynthesis) - Protocol: Secure WebSockets (
wss://)
- Framework: FastAPI (Python 3.10+)
- Server: Uvicorn (ASGI)
- Database: Google Cloud Firestore (NoSQL)
- AI Model: Google Gemini 2.0 Flash (
google-generativeaiSDK)
- Deployment: Configured for Render / Railway / Vercel (Frontend)
- Environment:
.envdriven configuration - Dependency Mgmt: pip / requirements.txt
- Python 3.10 or higher
- Google Cloud Platform account (Firestore enabled)
- Google AI Studio API Key
- Clone the repository
git clone https://github.com/ChilliRoger/kineo.git
cd kineo- Set up Virtual Environment
python -m venv .venv
# Windows
.\.venv\Scripts\Activate.ps1
# Mac/Linux
source .venv/bin/activate- Install Dependencies
pip install -r requirements.txt- Environment Configuration
Create a
.envfile in the root directory:
GOOGLE_API_KEY=your_gemini_api_key
GCP_PROJECT_ID=your_gcp_project_id
FIRESTORE_COLLECTION_CUSTOMERS=kineo_customers
FIRESTORE_COLLECTION_SESSIONS=kineo_sessions
# Optional: Service Account if not using default auth
GOOGLE_APPLICATION_CREDENTIALS=service-account.json- Start the Backend
uvicorn main:app --reloadServer starts at http://localhost:8000
-
Launch Frontend Open
http://localhost:8000/in your browser. -
Production Deployment
- Backend: Push to Render/Railway using the provided
render.yamlorProcfile. - Frontend: Deploy to Vercel/Netlify. Update
CONFIG_BACKEND_URLinindex.html.
"Where is my latest order?" "Has the package meant for Sarah arrived yet?"
"I want to return the bluetooth speaker." "This product is defective and I'm very unhappy."
"What is my current loyalty tier?" "Do I have any active subscriptions?"
GET /health
- Health check and model status.
- Response:
{"status": "ok", "model": "gemini-2.0-flash-exp"}
GET /customer/{customer_id}
- Fetch full customer profile and stats.
GET /orders/customer/{customer_id}
- List recent orders and shipping status.
Endpoint: /session
Client -> Server
{
"type": "transcript",
"text": "User spoken text"
}Server -> Client
// Agent Speech
{
"type": "audio",
"text": "I can help with that return..."
}
// UI Trigger
{
"type": "offer",
"data": {
"title": "20% Cashback",
"churn_score": 85,
"action": "refund_init"
}
}- Basic Voice Agent architecture
- Gemini 2.0 Integration
- Firestore logging
- Basic UI implementation
- Churn Scoring Algorithm
- Dynamic UI Cards (Offer/Cashback)
- Environment-agnostic Websockets
- Deployment configuration (Render/Vercel)
- Multi-lingual support (Spanish/French)
- Voice biometrics for authentication
- CRM Integration (Salesforce/HubSpot)
- Advanced visual dashboards for Admins
This project is licensed under the MIT License.
Built for the future of customer retention