Here I use various technologies to create a customer voice assistant assisted with tools.
This guide explains how to set up and run the entire Insta-Voice-Assistant project, including the frontend, backend services (token generation and LiveKit agent), Supabase database, and how to run tests.
- Git: For cloning the repository.
- Python: Version 3.10 or higher (project uses 3.11 recommended).
- Node.js and npm/yarn: For the frontend (e.g., Node.js >= 18, check
frontend/frontend/package.jsonfor specifics). - Firebase Project:
- A Firebase project is required.
- Enable Firebase Authentication (e.g., Email/Password and/or Google Sign-In).
- Download your Service Account Key JSON file (Firebase Console > Project Settings > Service Accounts > Generate new private key).
- Supabase Project:
- A Supabase project is required.
- Note your Supabase Project URL and
service_rolekey (oranonkey depending ondb_driver.pyneeds, butservice_roleis common for backend admin tasks like KB population).
- LiveKit Account/Server:
- A LiveKit Cloud account (e.g.,
wss://your-project.livekit.cloud) or a self-hosted LiveKit server. - You'll need your LiveKit API Key and API Secret.
- A LiveKit Cloud account (e.g.,
- OpenAI Account:
- An OpenAI API Key is needed for STT, LLM, TTS, and embedding generation.
-
Clone the Repository:
git clone <your-repository-url> cd Insta-Voice-Assistant-
-
Backend Environment Variables (
backend/.env):-
Navigate to the
backend/directory. -
Create a file named
.env(you can copybackend/.env.exampleif it exists). -
Add the following, replacing placeholders with your actual credentials:
# Firebase Admin SDK (absolute or relative path from backend/ to your downloaded JSON key) FIREBASE_ADMIN_SDK_CREDENTIALS_PATH="path/to/your/firebase-service-account-key.json" # LiveKit Credentials & URL LIVEKIT_API_KEY="YOUR_LIVEKIT_API_KEY" LIVEKIT_API_SECRET="YOUR_LIVEKIT_API_SECRET" LIVEKIT_URL="wss://your-livekit-server-url.livekit.cloud" # OpenAI API Key OPENAI_API_KEY="YOUR_OPENAI_API_KEY" # Supabase Credentials SUPABASE_URL="YOUR_SUPABASE_PROJECT_URL" # e.g., https://xyz.supabase.co SUPABASE_KEY="YOUR_SUPABASE_SERVICE_ROLE_KEY" # For admin tasks like KB population
-
Important:
- Ensure
FIREBASE_ADMIN_SDK_CREDENTIALS_PATHpoints correctly to your Firebase service account JSON file. - Add the service account JSON file itself (e.g.,
firebase-service-account-key.json) to your main.gitignorefile to prevent committing it.
- Ensure
-
-
Frontend Environment Variables (
frontend /frontend/.env):-
Navigate to the
frontend /frontend/directory. -
Create a file named
.env(or.env.localdepending on your frontend framework, e.g., Vite uses.env). -
Add your Firebase web app configuration (from Firebase Console > Project Settings > Your apps > Web app > SDK setup & config):
# Example for Vite (React) - adjust prefixes if needed for other frameworks VITE_FIREBASE_API_KEY="YOUR_FIREBASE_WEB_API_KEY" VITE_FIREBASE_AUTH_DOMAIN="YOUR_PROJECT_ID.firebaseapp.com" VITE_FIREBASE_PROJECT_ID="YOUR_PROJECT_ID" VITE_FIREBASE_STORAGE_BUCKET="YOUR_PROJECT_ID.appspot.com" VITE_FIREBASE_MESSAGING_SENDER_ID="YOUR_MESSAGING_SENDER_ID" VITE_FIREBASE_APP_ID="YOUR_WEB_APP_ID" # URL for the backend token service VITE_TOKEN_SERVICE_URL="http://localhost:8000" # Or whatever port you run token_service on
-
- Log in to your Supabase project dashboard.
- SQL Editor Navigation:
- Navigate to the "SQL Editor" section from the sidebar.
- Run SQL Scripts:
- Click "+ New query" for each script.
- Open the SQL files located in the
database_setup/directory of this project. - Execute them in the following order:
01_extensions.sql(This likely enablespgvectorand any other required PostgreSQL extensions).02_tables.sql(This should createuser_profiles,knowledge_articles,interaction_summaries, etc.)03_functions.sql(This should create functions likematch_knowledge_articlesfor RAG).
- Copy the content of each SQL file, paste it into the Supabase SQL Editor, and click "RUN". Verify each script executes successfully. Check the
TASK.MDto ensure all expected tables/functions are created.
-
Navigate to the Backend Directory:
cd backend # From project root
-
Create and Activate Python Virtual Environment:
python3 -m venv ai source ai/bin/activate(On Windows, use
ai\Scripts\activate) -
Install Python Dependencies:
pip install -r requirements.txt
-
Populate Knowledge Base (Optional - if you have sample data):
- If there's a script like
backend/populate_kb.py, you can run it to insert initial data into yourknowledge_articlestable. - Ensure your
backend/.envis configured, especiallyOPENAI_API_KEY(for embeddings) and Supabase credentials.
python populate_kb.py
- If there's a script like
-
Run the Backend Services: You'll typically run these in separate terminal windows/tabs. Ensure the virtual environment (
ai) is active in each.-
A. LiveKit Token Service (
token_service.py):- From the project root (
Insta-Voice-Assistant-/):uvicorn backend.token_service:app --reload --port 8000
- This service allows the frontend to get LiveKit tokens after Firebase login.
- From the project root (
-
B. LiveKit Agent (
main.py):- From the project root (
Insta-Voice-Assistant-/):python -m backend/main.py
- This is the AI voice assistant that will connect to LiveKit rooms.
- From the project root (
-
-
Navigate to the Frontend Directory:
- From the project root (
Insta-Voice-Assistant-/):cd "frontend /frontend" # Adjust if your path is different
- From the project root (
-
Install Node.js Dependencies:
npm install # or yarn install -
Run the Frontend Development Server:
npm run dev # or yarn dev- The frontend app should typically run on
http://localhost:5173. Check your terminal output for the exact URL.
- The frontend app should typically run on
- Ensure Backend Setup is Done:
- Python virtual environment (
ai) should be created and its dependencies installed.
- Python virtual environment (
- Activate Virtual Environment:
- If not already active in your terminal, from the
backend/directory:source ai/bin/activate
- If not already active in your terminal, from the
- Navigate to Project Root:
- Your tests might be configured to run from the project root.
cd .. # if you are in backend/
- Run Pytest:
or
pytest
python -m pytest
- This will discover and run tests (e.g., in the
tests/directory or files namedtest_*.py).
- This will discover and run tests (e.g., in the
- Start the Supabase service (it's always running in the cloud). Ensure schema is set up.
- Start the LiveKit Token Service (
backend/token_service.pyvia Uvicorn). - Start the LiveKit Agent (
backend/main.py). - Start the Frontend development server.
- Open your browser to the frontend URL.
- Sign up/Log in using Firebase on the frontend.
- The frontend should then request a LiveKit token from your
token_service. - With the token, the frontend connects to a LiveKit room where the
agentshould be waiting or will join.