Skip to content

Somtrip/VoiceRAGcare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Voice RAG Customer Care Assistant

A smart, voice-enabled customer support assistant built with Spring Boot (Java) and powered by Retrieval-Augmented Generation (RAG). It answers user queries from an FAQ knowledge base using AI, with voice interaction, semantic search, and real-time order tracking.

Live Demo Customer Support Assistant Spring Boot Java

Live Demo

Try it now: https://voiceragcare-production.up.railway.app/

Features

  • Voice & Text Input: Speak naturally or type your questions
  • Smart RAG System: Retrieves relevant information from FAQs with semantic search
  • Order Status Check: Real-time order tracking (with mock data)
  • Text-to-Speech: Hear spoken responses with interrupt capability
  • Beautiful Web UI: Modern, responsive interface
  • Fast Responses: Optimized for low latency
  • Source Citations: Always shows where information comes from

πŸš€ Quick Setup

Prerequisites

  • Java 21 or later
  • Maven (included with wrapper)
  • Gemini API Key from Google AI Studio

Installation

  1. Clone the repository
git clone https://github.com/Somtrip/VoiceRAGcare.git
cd VoiceRAGcare
  1. Set up environment
# Copy the example environment file
cp env.example .env

# Add your Gemini API key
echo "GEMINI_API_KEY=your_actual_api_key_here" >> .env
  1. Run the application
# Using Maven wrapper (recommended)
./mvnw spring-boot:run

# Or with installed Maven
mvn spring-boot:run
  1. Open your browser
http://localhost:8080

That's it! The application will automatically:

  • Load sample FAQs into the database
  • Generate embeddings for semantic search
  • Start the web server

🎯 How It Works

Ask Anything

  • "What's your return policy?"
  • "How do I track my order?"
  • "What payment methods do you accept?"
  • "What's the status of order 12345?"

Two Smart Modes

  1. FAQ Mode: Answers questions using your knowledge base with source citations
  2. Order Status Mode: Checks order tracking and delivery estimates

Intelligent Processing

  • Intent Classification: Automatically detects if you're asking about orders or general questions
  • Semantic Search: Finds the most relevant FAQs using AI embeddings
  • Keyword Fallback: Works even when embeddings aren't available
  • Context-Aware Responses: Generates natural, helpful answers

API Usage

Quick Testing

# Health check
curl http://localhost:8080/api/assistant/health

# Chat endpoint
curl -X POST http://localhost:8080/api/assistant/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"What is your return policy?"}'

# Test order status
curl -X POST http://localhost:8080/api/assistant/test-order \
  -H "Content-Type: application/json" \
  -d '{"orderId":"12345"}'

Debug Endpoints

# Check loaded FAQs
curl http://localhost:8080/api/assistant/debug/faqs

# Test search
curl "http://localhost:8080/api/assistant/debug/search?query=returns"

βš™οΈ Configuration

Environment Variables

Create a .env file in the root directory:

GEMINI_API_KEY=your_gemini_api_key_here
SERVER_PORT=8080  # Optional, defaults to 8080

Application Properties

Key settings in src/main/resources/application.properties:

# Server
server.port=8080

# Database (H2 in-memory)
spring.datasource.url=jdbc:h2:mem:testdb

# Gemini AI
gemini.api.key=${GEMINI_API_KEY}

# CORS (enabled for all origins in development)
spring.web.cors.allowed-origins=*

πŸ“ Project Structure

src/
β”œβ”€β”€ main/
β”‚   β”œβ”€β”€ java/com/customercare/
β”‚   β”‚   β”œβ”€β”€ controller/          # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ service/            # Business logic
β”‚   β”‚   β”œβ”€β”€ model/              # Data models
β”‚   β”‚   └── repository/         # Database operations
β”‚   └── resources/
β”‚       β”œβ”€β”€ static/             # Web UI (HTML, CSS, JS)
β”‚       β”œβ”€β”€ data/               # Sample FAQs
β”‚       └── application.properties

Key Components

  • VoiceAssistantController: Handles HTTP requests and responses
  • RAGService: Implements retrieval-augmented generation
  • GeminiService: Communicates with Google's Gemini AI
  • OrderStatusService: Mock order tracking system
  • DataIngestionService: Loads FAQs and generates embeddings

🚒 Deployment

Already Deployed!

This project is live at: https://voiceragcare-production.up.railway.app/

Deploy Your Own

The app is ready for deployment on any Java-compatible platform:

Railway (Used for current deployment)

# Connect your GitHub repo and set GEMINI_API_KEY in environment variables

πŸ”§ Customization

Adding Your Own FAQs

Edit src/main/resources/data/sample-faqs.json:

{
  "question": "Your question here?",
  "answer": "Your detailed answer here.",
  "category": "category-name",
  "sourceDocument": "Source Document Name"
}

πŸ“Š Monitoring

The application includes built-in health checks and debugging endpoints:

  • GET /api/assistant/health - Service status
  • GET /api/assistant/debug/faqs - FAQ statistics
  • GET /api/assistant/debug/search?query=... - Search debugging

Need help?


⭐ Star this repo if you find it helpful!

About

A voice-enabled customer care assistant that answers user questions using Retrieval-Augmented Generation (RAG) with a small FAQ knowledge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors